Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Invalid state, the Connection object is closed

843859Jul 3 2006 — edited Jul 11 2006
Hello everyone,

I have a method that creates a table (this is part of a transaction) in a sql server database:
public void createTempTable() {
		PreparedStatement pstmt = null;
		try {	      
			pstmt = this.cn.prepareStatement("CREATE TABLE member ([member_number] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AI NOT NULL);");
			pstmt.executeUpdate();	
			pstmt.close();
		} catch (Exception e) {
			e.printStackTrace();
			this.error = true;
		}
		finally {
			if (pstmt != null) {	try {pstmt.close();} catch(Exception e){} pstmt = null;	}
		}
	}
then i do commit and finally i close the connection.

But i must be doing something wrong since i am getting the following exception:
java.sql.SQLException: Invalid state, the Connection object is closed.
	at net.sourceforge.jtds.jdbc.ConnectionJDBC2.checkOpen(ConnectionJDBC2.java:1494)
	at net.sourceforge.jtds.jdbc.ConnectionJDBC2.prepareStatement(ConnectionJDBC2.java:2177)
	at com.atloader.dao.SQLServerMemberDAO.createTempTable(SQLServerMemberDAO.java:63)
.....
can someone help me? i thought it could be a driver issue (i am using jtds) but the same thing happens with ms jdbc driver.

Thanks in advance
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 8 2006
Added on Jul 3 2006
5 comments
1,671 views