File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Please Help, Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Please Help," Watch "Please Help," New topic
Author

Please Help,

Srini Kesavan
Greenhorn

Joined: Jan 18, 2003
Posts: 18
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


------------------

SCDJWS,SCWCD,SCJP
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Sounds like the driver you are using does not support transactions.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Xuening Ma
Greenhorn

Joined: Jul 25, 2002
Posts: 6
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)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Please Help,