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