kazu2012 / persevere-framework

Automatically exported from code.google.com/p/persevere-framework
0 stars 0 forks source link

Change how the ID parameter is set in PreparedStatements #104

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I noticed this bug in the DatabaseTableDataSource.mapObject method while
trying to use the PostgreSQL driver with Persevere.

When setting the id parameter in PreparedStatement try to use setInt on
numeric values as some JDBC drivers are picky.  Fall back to setString when
if an int cannot be parsed.

I've attached a patch that solves this using the following way:

try {                           loadStatement.setInt(1, Integer.parseInt(objectId));
} catch (NumberFormatException e) {
loadStatement.setString(1, objectId);
}

Original issue reported on code.google.com by schisamo on 25 Feb 2009 at 5:15

Attachments:

GoogleCodeExporter commented 8 years ago
Thank you for the report/patch!

Original comment by kris...@gmail.com on 25 Feb 2009 at 4:07