Result Set error
Im getting the following error, where the program completely crashes out.... Exception java.sql.SQLException: Closed Connection: next
Im retrieving data from one db and updating another, however after retrieving data fron one db, the program kills itself. My methods are synchronized and the connection information is correct....
Any suggestion would be grealty recieved,
thanks,
brian
You didn't prematurely close the prepared statement, result set or connection, perhaps?- Saish"My karma ran over your dogma." - Anon
Saish at 2007-6-29 14:59:51 >

It is definite that you have already used one of the database objects. If you can post your code, it may be feasible to point out the bug. Are you using connection pooling, btw ?
rathsb at 2007-6-29 14:59:51 >

Sound for replying lads, i got it sorted...
However - - - - - - one more problem, Becuase the tables are a replication of one another, im trying to cross data over but when i print out the primary key in one db, and try to enter it into another db im getting an invalid number exception....
heres the code....
//read out the details of the person
for (int i=0;i<vector.size();i++) {
localDetails = new String [6];
localDetails = (String[]) v.elementAt (i);
//insert details
sqp = "INSERT INTO TABLE (table_id, f_name, l_name, DOB, ADDRESS) VALUES (table_id_seq.NEXTVAL, ' " + localDetails [0] + " ',' " + localDetails [1] + " ',' " + localDetails [2] + " ',' " + localDetails [3] + "')";
db2.update (sql);
sql = null;
//another insert
sql = "INSERT STATEMENT " + localDetails [4] + ")"
db2.update (sql);
sql = null;
//another insert
sql = "Bla"';
db2.update (sql);
sql = null;
//end of method....
>
Use a PreparedStatement rather than building a totally dynamic Statement object. Substitute question marks (?) for the bind variable positions and use PreparedStatement.setXXX() methods.
String sql = "INSERT INTO foo VALUES(?,?, ?)";
PreparedStatement stmt = connection.prepareStatement(sql);
stmt.setInteger(1, new Integer(1));
stmt.setString(2, "Hello world");
stmt.setObject(3, new Date());
stmt.executeUpdate();
- Saish
"My karma ran over your dogma." - Anon
Saish at 2007-6-29 14:59:51 >
