drivers.
The first fix fixes the PreparedStatement object to not allocate
unnecessary objects when converting native types to Stings. The old
code used the following format:
(new Integer(x)).toString()
whereas this can more efficiently be occompilshed by:
Integer.toString(x);
avoiding the unnecessary object creation.
The second fix is to release some resources on the close() of a
ResultSet. Currently the close() method on ResultSet is a noop. The
purpose of the close() method is to release resources when the ResultSet
is no longer needed. The fix is to free the tuples cached by the
ResultSet when it is closed (by clearing out the Vector object that
stores the tuples). This is important for my application, as I have a
cache of Statement objects that I reuse. Since the Statement object
maintains a reference to the ResultSet and the ResultSet kept references
to the old tuples, my cache was holding on to a lot of memory.
Barry Lind
*/
public void setByte(int parameterIndex, byte x) throws SQLException
{
- set(parameterIndex, (new Integer(x)).toString());
+ set(parameterIndex, Integer.toString(x));
}
/**
*/
public void setShort(int parameterIndex, short x) throws SQLException
{
- set(parameterIndex, (new Integer(x)).toString());
+ set(parameterIndex, Integer.toString(x));
}
/**
*/
public void setInt(int parameterIndex, int x) throws SQLException
{
- set(parameterIndex, (new Integer(x)).toString());
+ set(parameterIndex, Integer.toString(x));
}
/**
*/
public void setLong(int parameterIndex, long x) throws SQLException
{
- set(parameterIndex, (new Long(x)).toString());
+ set(parameterIndex, Long.toString(x));
}
/**
*/
public void setFloat(int parameterIndex, float x) throws SQLException
{
- set(parameterIndex, (new Float(x)).toString());
+ set(parameterIndex, Float.toString(x));
}
/**
*/
public void setDouble(int parameterIndex, double x) throws SQLException
{
- set(parameterIndex, (new Double(x)).toString());
+ set(parameterIndex, Double.toString(x));
}
/**
*/
public void close() throws SQLException
{
- // No-op
+ //release resources held (memory for tuples)
+ rows.setSize(0);
}
/**
*/
public void setByte(int parameterIndex, byte x) throws SQLException
{
- set(parameterIndex, (new Integer(x)).toString());
+ set(parameterIndex, Integer.toString(x));
}
/**
*/
public void setShort(int parameterIndex, short x) throws SQLException
{
- set(parameterIndex, (new Integer(x)).toString());
+ set(parameterIndex, Integer.toString(x));
}
/**
*/
public void setInt(int parameterIndex, int x) throws SQLException
{
- set(parameterIndex, (new Integer(x)).toString());
+ set(parameterIndex, Integer.toString(x));
}
/**
*/
public void setLong(int parameterIndex, long x) throws SQLException
{
- set(parameterIndex, (new Long(x)).toString());
+ set(parameterIndex, Long.toString(x));
}
/**
*/
public void setFloat(int parameterIndex, float x) throws SQLException
{
- set(parameterIndex, (new Float(x)).toString());
+ set(parameterIndex, Float.toString(x));
}
/**
*/
public void setDouble(int parameterIndex, double x) throws SQLException
{
- set(parameterIndex, (new Double(x)).toString());
+ set(parameterIndex, Double.toString(x));
}
/**
*/
public void close() throws SQLException
{
- // No-op
+ //release resources held (memory for tuples)
+ rows.setSize(0);
}
/**