Quoting Mike Moran <mik...@ma...>:
> 1 - Postgres 7.4 now claims to support status codes and the like on
> SQLException. Can Spring use these out-of-the-box or would a specific
> mapping hierarchy have to be written?
Mike,
I recently installed this version, so next step is obviously for me to connect
and force an error to get a look at the error codes. Have you seen a list of
what error codes they are using? We should be able to map their codes to our
exception hierarchy the way we do it for other databases. This is something we
should do before RC1 - doubt we will have time before M4.
Now for something completely different:
I have recently added support for updatable result sets in a class called
org.springframework.jdbc.object.UpdatableSqlQuery. It is used the same way as
the MappingSqlQuery, except that you override updateRow() instead of mapRow()
and in the query.execute you pass in a Map that can be used to look up values
for the update. My example uses the primary key as the lookup value in a HashMap.
Example:
class CustomerUpdateQuery extends UpdatableSqlQuery {
public CustomerUpdateQuery(DataSource ds) {
super(ds, "SELECT ID, NAME WHERE ID < ?");
declareParameter(new SqlParameter(Types.NUMERIC));
compile();
}
protected Object updateRow(ResultSet rs, int rownum, Map context)
throws SQLException {
rs.updateString(2, (String) context.get(new Integer(rs.getInt("ID"))));
return null; // we can create an object if we want to return something
}
};
CustomerUpdateQuery query = new CustomerUpdateQuery(dataSource);
Map values = new HashMap(2);
values.put(new Integer(1), "Rod");
values.put(new Integer(2), "Thomas");
query.execute(2, values);
Thomas
|