too many connections
We have an application written some years ago. The hosters, moving to a 2003 server found that the app times out while it's building a lookup table.
According to them its the following bit of code that's responsible.
Recordset donorIDs = null;
try {
donorIDs = objConn.execute("SELECT DonorID FROM Donors ORDER BY DonorID");
while (!donorIDs.getEOF()) {
String donorID = donorIDs.getField("DonorID").getString();
String sql="INSERT INTO DonorLookup (DonorID, HashValue) " +
"VALUES (" + donorID + ",\"" + getHashValue(donorID) + "\")";
objConn.execute(sql);
donorIDs.moveNext();
}
}
This is their comment about it:
In particular its objConn.execute, which almost opens a new connection everytime its run. Its ironic but if the code was changed to a Recordset and the loop created a new item in the recordset this would only use 1 connection and would work fine ?not 100% sure about this but its something I would try if I had the correct compiler.
I say the system 慳lmost?opens a new connection, it opens a new connection if the SQL Server isn抰 given time to complete the task.
Could anyone help with an alternative method, a CommandObject has been suggested as well, that would get rid of this connection 'overload'.
Not being a Java developer myself I have to ask, once the alternative snippet is supplied, how can I incorporate it into the compiled java class?
Thanks in advance
JV

