java.sql.SQLException:General error Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of java.sql.SQLException:General error without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I’m getting java.sql.SQLException: General error I’m trying to delete data from Access DataBase but it throws that error. try{

                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);
            }

Data from DataBase inserts perfectly in JTable, i had JOptionPane.showMessageDialogs to check the array if it isn’t null, but the array is filled whit values.

I tried to delete by one value but it still gets the same error…

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)

Answer

Use executeUpdate for database write operations

pst.executeUpdate();
We are here to answer your question about java.sql.SQLException:General error - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji