Unable to catch sql exception

User 818520b6b8

03-05-2005 13:50:01

I have the following java method:





private void deleteMolecule()


{


UpdateHandler uh = null;





try


{


uh = new UpdateHandler(ch,UpdateHandler.UPDATE,structureTableName, "");


uh.deleteRows(ch,structureTableName,"WHERE cd_id = " + entryNumber);


}


catch (Exception e)


{


JOptionPane.showMessageDialog(this,


"Error deleting structure: " + e.getMessage(),


"Error",


JOptionPane.ERROR_MESSAGE);


}


finally


{


try


{


uh.close();


}


catch (SQLException ex) {}


}


}





It's called when user wants to delete a molecule.





But if user doesn't have sufficient privileges in oracle database to delete on structure table an exception is raised but I won't ever be able to catch it. Where is the problem?





This is the stack trace for the error:





java.sql.SQLException: ORA-01031: insufficient privileges








at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)





at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305)





at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272)





at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623)





at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:112)





at oracle.jdbc.driver.T4CStatement.execute_for_rows(T4CStatement.java:474)





at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1028)





at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1516)





at chemaxon.jchem.db.UpdateHandler.deleteRows(UpdateHandler.java:1868)





at jchem.UpdateStructure.deleteMolecule(UpdateStructure.java:324)





at jchem.UpdateStructure.deleteButton_actionPerformed(UpdateStructure.java:557)





at jchem.UpdateStructure.access$6000171(UpdateStructure.java:53)





at jchem.UpdateStructure$2.actionPerformed(UpdateStructure.java:389)





at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)





at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)





at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)





at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)





at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)





at java.awt.Component.processMouseEvent(Component.java:5100)





at java.awt.Component.processEvent(Component.java:4897)





at java.awt.Container.processEvent(Container.java:1569)





at java.awt.Component.dispatchEventImpl(Component.java:3615)





at java.awt.Container.dispatchEventImpl(Container.java:1627)





at java.awt.Component.dispatchEvent(Component.java)





at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java)





at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)





at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)





at java.awt.Container.dispatchEventImpl(Container.java:1613)





at java.awt.Window.dispatchEventImpl(Window.java)





at java.awt.Component.dispatchEvent(Component.java)





at java.awt.EventQueue.dispatchEvent(EventQueue.java:458)





at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)





at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)





at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)





at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)





at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

User 818520b6b8

03-05-2005 13:55:39

I have a similiar code which implements an update on the structure table and the exception is catched when an sql error occurs.

ChemAxon 9c0afc9aaf

03-05-2005 15:44:21

Hi,





I have inspected our code, and the following seem to happen:





1. an exception is thrown by the JDBC driver


2. we catch the exception


3. we print the stack trace and do not re-throw the exception (this is a bug)


4. there is no exception left for your try-catch pair to catch.





We will fix this in the next bugfix release, thank you for reporting the problem.





Best regards,





Szilard