I'm using javax.sql.rowset.JdbcRowSet
and com.sun.rowset.JdbcRowSetImpl
to manipulate data. Everything works fine, but I'm getting a warning that I might get a resource leak.
Also, I'm using singleton Connection in JdbcRowSet constructor which is always open, but when I use JdbcRowSet close()
I can't use it in next method.
Here's the code.
public static Connection conn = DBConnection.getInstance()
.getConnection();
(not the exact work, only a sample code)
private static void function1() {
try {
JdbcRowSet myrs = new JdbcRowSetImpl(conn);
myrs.setCommand("SELECT * FROM `table1`");
myrs.execute();
//result iteration
myrs.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
private static void function2() {
same as function1 (for example, not really important here)
}
public static void start(){
function1();
function2();
}
When it gets to execute myrs
in function2()
I get an error:
at com.sun.rowset.JdbcRowSetImpl.execute(Unknown Source)
Anyone knows how to solve it?