[英]what does this Exception mean ??java.sql.SQLException: General error , in Java with Access DB?
我正在嘗試將數據插入存儲在我的計算機上的Access數據庫中,但是當我運行以下代碼時,會出現異常
這是例外:
2011年12月14日下午7:22:21 Ass3_lab.afterLogin $ 8 actionPerformed SEVERE:null java.sql.SQLException:sun.jdbc.odbc上sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6986)的常規錯誤。位於sun.jdbc.odbc的sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3110)的sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)的JdbcOdbc.standardError(JdbcOdbc.java:7114) .JdbcOdbcStatement.executeUpdate(JdbcOdbcStatement.java:288)
我寫了這個方法來插入:
public void saveDataInDB(int std_id,int course_id,String semester_no) throws SQLException {
Connection conn=null;
PreparedStatement pstmt=null;
String insertSQL="insert into Registered_course (std_id,course_id,semester_number) values(? , ?,?)";
try{
conn=con.getConnection();
pstmt=conn.prepareStatement(insertSQL);
pstmt.setInt(1,std_id);
pstmt.setInt(2,course_id);
pstmt.setString(3,semester_no);
pstmt.executeUpdate();
pstmt.close();
conn.close();
} // end of try
finally {
if(conn != null){
conn.close();
}
if (pstmt != null) {
try {
pstmt.close();
} catch (Exception ignore) {
}
}
}
}
我在一個動作監聽器中調用了這樣的方法:
save.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
try {
Login l = new Login();
for(int t=0;t<=numberOfRowsInTableOne;t++){
i.saveDataInDB(l.idFromDB,course_id[t],semester_no);
}
} catch (SQLException ex) {
Logger.getLogger(afterLogin.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
有人可以幫我解決這個問題嗎?
GeneralError非常具有誤導性。 它可能發生的原因有多種:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.