gpt4 book ai didi

java.sql.SQLException :General error

转载 作者:行者123 更新时间:2023-12-02 04:57:04 25 4
gpt4 key购买 nike

我收到java.sql.SQLException:一般错误我试图从 Access DataBase 中删除数据,但它引发了该错误。尝试{

                conn = DBConnection.DBConnector();
pst = conn.prepareStatement("DELETE FROM Table1 where (name, level, study, 1pn, 2pn, 1pk, 2pk, summ, teori, p-d, ind, gat, pav) values (?,?,?,?,?,?,?,?,?,?,?,?,?)");

pst.setString(1, (String) dsr[0]);
pst.setString(2, (String) dsr[1]);
pst.setString(3, (String) dsr[2]);
pst.setDouble(4, (double) dsr[3]);
pst.setDouble(5, (double) dsr[4]);
pst.setDouble(6, (double) dsr[5]);
pst.setDouble(7, (double) dsr[6]);
pst.setDouble(8, (double) dsr[7]);
pst.setDouble(9, (double) dsr[8]);
pst.setDouble(10, (double) dsr[9]);
pst.setDouble(11, (double) dsr[10]);
pst.setDouble(12, (double) dsr[11]);
pst.setDouble(13, (double) dsr[12]);

pst.executeUpdate();
pst.close();
JOptionPane.showMessageDialog(null, "Data delited!");

}catch(Exception e){
throw new RuntimeException(e);
}

来自数据库的数据完美插入到 JTable 中,我有 JOptionPane.showMessageDialogs 来检查数组是否不为空,但数组填充了白色值。

我尝试删除一个值,但仍然出现相同的错误...

Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: java.sql.SQLException: General error
Caused by: java.sql.SQLException: General error
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLExecute(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeQuery(Unknown Source)
at Main$ButtonEditor.getCellEditorValue(Main.java:442)

最佳答案

使用executeUpdate进行数据库写入操作

pst.executeUpdate();

关于java.sql.SQLException :General error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28658188/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com