JDBC problems
Posted in 1999
Topics: Connectivity: ODBC / JDBC / .NET, Java & JDBC Development
Hi! I wrote a short program in java. It is just simple query program where it step through a table with ~400000 records. The problem is that after a random number (in range from 20000 - 300000) of quries program quits. I tried this program on IDS7.3 on Linux, SCO in different combination of JDK and JDBC drivers but always with the same result. Here is a part of a program ... connection stuff here deleted for (int iii =1;iii<400000;iii++) { sql_str = "SELECT * FROM krvodajalec WHERE id="+iii; ResultSet rs = sq_stmt.executeQuery(sql_str); while (rs.next()) { int id = rs.getInt("id"); System.out.println("ID je : " + id); } } //for } catch (SQLException e) { System.out.println("ERROR: failed to connect!"); } ....some more stuff some ideas what could be wrong? Thanx, damijan
You must close your cursor after you are done with the result set. JDBC (or informix's JDBC) will run out of memory and that is the problem you are seeing. In article <376A2C64.6BBC4D76@animus.mf.uni-lj.si>, Damijan Sencar <dsencar@animus.mf.uni-lj.si> writes: >Hi! > >I wrote a short program in java. >It is just simple query program where it step through a table with >~400000 records. >The problem is that after a random number (in range from 20000 - >300000) >of quries program quits. > >I tried this program on IDS7.3 on Linux, SCO in different combination of >JDK and JDBC drivers >but always with the same result. > >Here is a part of a program > >.... connection stuff here deleted > > for (int iii =1;iii<400000;iii++) > { > > sql_str = "SELECT * FROM krvodajalec WHERE id="+iii; > ResultSet rs = sq_stmt.executeQuery(sql_str); > > while (rs.next()) > { > int id = rs.getInt("id"); > > System.out.println("ID je : " + id); > > } > } //for > > } > catch (SQLException e) > { > System.out.println("ERROR: failed to connect!"); > } > >.....some more stuff > >some ideas what could be wrong? > >Thanx, > >damijan -- -- Dari Shirazi | Internet: dshirazi@uhl.uiowa.edu The University of Iowa - Hygienic Lab | Voice: (319) 335-4500 Oakdale Research Campus, OH-E5B | Fax: (319) 335-4555 Iowa City, IA 52242 |