[問題] 忽略已有的primary key
怎麼樣才能夠忽略掉已經有的primary key 然後不斷地執行呢,請各位先進指點迷津>"<
一個txt檔有7-8個SQL insert語句,有五百多個檔案,使用java 自動執行完所有檔案。
我的程式可以跑,但是遇到已存在的primary key就會報錯停下來。
下面是主要的一段
/*抓取資料夾下所有檔案*/
for (Path pathFile: stream) {
System.out.println(pathFile.getFileName());
/*讀取檔案內容*/
Path file = Paths.get(dir+"/"+pathFile.getFileName());//組成檔案路徑
List<String> str;
str = Files.readAllLines(file);
String temp = new String();
for(String item : str){
temp = temp + item;
}
/*SQL語法*/
Statement stmt = conn.createStatement();
String query = new String(temp);
boolean result = stmt.execute(query);
System.out.println(result);
}
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.44.107.204
※ 文章網址: https://www.ptt.cc/bbs/java/M.1427620754.A.276.html
→
03/29 17:24, , 1F
03/29 17:24, 1F
推
03/29 20:07, , 2F
03/29 20:07, 2F
推
03/29 20:14, , 3F
03/29 20:14, 3F
→
03/29 20:14, , 4F
03/29 20:14, 4F
→
03/30 21:49, , 5F
03/30 21:49, 5F
java 近期熱門文章
PTT數位生活區 即時熱門文章