Hi, Maybe it would help to close the prepared statement befor you close the connection, which also would be the natural way of cleaning up.
Bernt >>>>>>>>>>>> Shambhu wrote (2007-03-21 18:55:29): > Hi, > > I am using Cloudscape(IBM Cloudscape Version 10.1) and derbyclient.jar > provided by derby. Following are the code I am using for clean the database > connection and also PreparedStatement. > > > > public void cleanup(Connection aoConnection, > > PreparedStatement aoPreparedStatement) { > > try{ > > if(!(aoConnection ==null || aoConnection.isClosed())) > > aoConnection.close();//Release Connection > > if(aoPreparedStatement != null) > > aoPreparedStatement.close(); > > }catch(SQLException aoSQLException){ > > aoSQLException.printStackTrace(); > > } > > } > > > > But some time this method call get hang. Can any one tell me why it is > happening? > > > > I have one more problem with this database. I am updating a table using > following code. > > > > //Table create script > > CREATE TABLE TABLE_MEMORY ( > > MEMORY_ID BIGINT NOT NULL GENERATED ALWAYS AS > IDENTITY, > > MEMORY SMALLINT, > > PRIMARY KEY (MEMORY_ID) > > ); > > > > //JAVA Code > > Connection aoConnection = getConnection(); > > PreparedStatement psUpdate = aoConnection.prepareStatement("UPDATE > TABLE_MEMORY SET MEMORY=? WHERE MEMORY_ID=?"); > > psUpdate.setInt(counter++, 38650); > > psUpdate.setInt(counter++, 15254); > > int updated = psUpdate.executeUpdate(); > > > > If I run above code, executeUpdate method does not throw any exception and > always returns value 1. But, due to size of value I am setting (38650) is > more than size of smallint, so it does not update database. > > Can any one tell me why value return by executeUpdate method is 1 even > database update is failed? > > > > For any reply thanks in advance. > > > > Thanks & Regards > > Shambhu Kumar Sinha > > > -- Bernt Marius Johnsen, Database Technology Group, Staff Engineer, Technical Lead Derby/Java DB Sun Microsystems, Trondheim, Norway
signature.asc
Description: Digital signature