I’ve been loading a growing and growing ResultSet into memory and until now it really hasn’t been an issue. It is now too large to reasonably work with. I’ve looked into creating scrollable result sets, however I’m having some trouble implementing it. Here’s what I’ve tried:
Statement stmt = con.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY);
stmt.setFetchSize(Integer.MIN_VALUE);
try {
if (stmt.execute("SELECT text, value FROM " + db)) {
rs = stmt.getResultSet();
} else {
System.err.println("select failed");
}
Is there some other parameter for the Statement that I’m missing? Or is there another option that I have to set somewhere else?
EDIT:
Turns out the issue wasn’t the stream itself, but how I was updating the RS. Can I not update the RS if it’s streaming? Console is popping off the following:
SQLException: Operation not supported for streaming result sets
SQLState: S1009
VendorError: 0
Here’s the code I’m using to update the DB after they’ve been processed:
rs.getDouble("value");
if (rs.wasNull()) {
StringValue analysis = new StringValue(dict);
int id = rs.getRow();
String entry = rs.getString("text");
double val = analysis.analyzeString(entry);
pst.setDouble(1, val);
st.setInt(2, id);
System.out.println(id+": " + val + " : " + rs.getString(5));
pst.executeUpdate();
The prepared statement is structured like so:
pst = conn.prepareStatement("UPDATE "+ db +" SET value=? WHERE id=?");
Fairly straightforward, StringValue method analyzeString is essentially sentiment analysis of the input string.
Limit your rows:
or