Hi, all, My code is like ============================== Connection conn = ... Statement stmt = conn.createState(); Statement stmt2 = conn.creatState(); ResultSet rs = stmt.executeQuery("select * from mytable"); while( rs.next() ) { ResultSet rs2 = stmt2.executeQuery("select * from mytable222"); // error here !!! } } ====================== I got Exception ====================== ava.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6031) at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6188) at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:2494) at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:314) at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:229) ================================== But if I change my code to ======================== Connection conn = ... Connection conn2 = ... // new connection Statement stmt = conn.createState(); Statement stmt2 = conn2.creatState(); // using conn2 ======================== it works. My question is that "do I really need another Connectin?" Thanks! -Zhining
ZhiningZhang
Greenhorn
Joined: Jun 13, 2001
Posts: 18
posted
0
hi, i solved my problem. Connection conn = ... Statement stmt = conn.createState(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); Statement stmt2 = conn.creatState(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); ======= it works by using only one connection. Thanks anyway! -Zhining