<$BlogRSDUrl$> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } }
Wednesday, May 26, 2004

JDBC: User Defined Types 

#3
A new Connection object created using the JDBC 2.1 core API has an
initially empty type map associated with it. A user may enter a custom
mapping for a UDT in this type map. When a UDT is retrieved from a data
source with the method ResultSet.getObject, the getObject method will check
the connection's type map to see if there is an entry for that UDT. If so,
the getObject method will map the UDT to the class indicated. If there is no
entry, the UDT will be mapped using the standard mapping.

A user may create a new type map, which is a java.util.Map object,
make an entry in it, and pass it to the java.sql methods that can perform
custom mapping. In this case, the method will use the given type map instead
of the one associated with the connection.

For example, the following code fragment specifies that the SQL type
ATHLETES will be mapped to the class Athletes in the Java programming
language. The code fragment retrieves the type map for the Connection object
con, inserts the entry into it, and then sets the type map with the new
entry as the connection's type map.

java.util.Map map = con.getTypeMap();
map.put("mySchemaName.ATHLETES", Class.forName("Athletes"));
con.setTypeMap(map);

Comments: Post a Comment

This page is powered by Blogger. Isn't yours?