0
try {
Class.forName("com.mysql.jdbc.Driver");
Connection dbaTo = DriverManager.getConnection("jdbc:mysql://localhost:3306/ourDB1", "root", "");
PreparedStatement stat2 = dbaTo.prepareStatement("SELECT * FROM tblEntry");
journEnt = journCombo.getSelectedItem().toString();
String sqlbebe = "INSERT INTO tblJournEnt(strEntJournCode, strEntJournType) VALUES (?, ?)";
PreparedStatement stat3 = dbaTo.prepareStatement(sqlbebe);
ResultSet resultaNgSet = stat2.executeQuery();
if(resultaNgSet.next()) {
do{
kuhaEntCode = resultaNgSet.getString(1);
substring2 = kuhaEntCode.substring(Math.max(kuhaEntCode.length() - 3, 0));
}while(resultaNgSet.next());
} //IF////////////////////////////////////////////////////////////
else{
stringsaEnt = "Ent000";
}
int convertToInt2 = Integer.parseInt(substring2);
int addition2 = convertToInt2 + 1;
if (addition2 >= 10) {
String prd = "ent0";
stringsaEnt = prd + addition2;
}
else {
String prd2 = "ent00";
stringsaEnt = prd2 + addition2;
//pasaEnt(stringsaEnt);
}
stat3.setString(1, stringsaEnt);
stat3.setString(2, journEnt);
stat3.addBatch();
stat3.executeBatch();
stat3.close();
}catch(Exception saiko) {
}
這是我的代碼,我不知道,但它不會插入到我的數據庫插入到MySQL不工作
永遠永遠永遠永遠永遠永遠永遠永遠永遠永遠永遠永遠永遠永遠永遠永遠永遠永遠總是關閉你的'連接'在'finally'塊 –