I am having a problem with cursors on an Oracle 7.3.4 database.
I grab the connection from Orion as follows:
public static Connection getConnection() throws SQLException {
try {
javax.naming.Context context = new javax.naming.InitialContext();
javax.sql.DataSource ds = (javax.sql.DataSource)context.lookup("jdbc/CDE_JBDS");
return ds.getConnection();
} catch (javax.naming.NamingException ex) {
ex.printStackTrace(System.err);
throw new SQLException(e.getMessage());
}
}
I then get run a query and load the data into an ArrayList of objects:
public ArrayList selectRows(String sql) throws SQLException {
ArrayList retRow = new ArrayList();
java.sql.Connection con = null;
Statement stmt = null;
ResultSet rs = null;
ResultSetMetaData rsmd = null;
try {
con = DBSession.getConnection ();
stmt = con.createStatement ();
rs = stmt.executeQuery (sql);
rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
while (rs.next()) {
Row row = new Row();
for (int col = 1; col <= columnCount; col++)
row.setProperty (col, rs.getString(col), rsmd);
retRow.add (row);
}
rs.close ();
stmt.close();
} catch (SQLException e) {
e.printStackTrace(System.err);
throw e;
} finally {
try { stmt.close(); } catch (Exception e) {}
try { rs.close(); } catch (Exception e) {}
try { con.close(); } catch (Exception e) {}
stmt = null;
rs = null;
con = null;
return retRow;
}
}
For some reason I keep running out of cursors. Is there something I am doing wrong.
SnowWolf