Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Please Help,

 
Srini Kesavan
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i set this conn.setAutoCommit(false); (conn - Connection) The following exception is being thrown.
[Microsoft][ODBC Microsoft Access Driver]Attribute cannot be set now
Here is my code. I would highly appreciate if anyone can suggest the reason for this.
public void actionPerformed(ActionEvent e) {
if(e.getSource() == update) {
try {
System.out.println (conn.getAutoCommit());
conn.setAutoCommit(false);
System.out.println (conn.getAutoCommit()); Statement stmt = conn.createStatement(); stmt.executeUpdate("UPDATE EMPLOYEE SET FNAME = 'John' WHERE SSN = '123456789' ");
conn.commit();

}// end of try block
catch (SQLException sqex) {
try {
conn.rollback();
}
catch(Throwable t) {}
System.out.println("error ");
System.out.println(sqex.getSQLState());
System.out.println(sqex.getMessage());
}// end of catch block
}// end of if block
} // end of action performed method


------------------
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like the driver you are using does not support transactions.
 
Xuening Ma
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, guy:
You must have open statement and let it still open when you setAttribute, just close all of the Statement&resultset based on this connection, you will get it.
(I met this problem also, I resolved it)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic