File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes contents of Map Object in setTypeMap? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "contents of Map Object in setTypeMap?" Watch "contents of Map Object in setTypeMap?" New topic

contents of Map Object in setTypeMap?

Raj Chila
Ranch Hand

Joined: Mar 18, 2004
Posts: 128

Hi all,

I wonder if some one could give me a quick intro to what the Map Objects keys and corresponding values should be?

I have some proprietory Datatypes, in a proprietory Persistence Framework, and we have to depend on reflection to convert the type to "JDBC type" at runtime. I think we dont have to do this if we can set the TypeMap at the time of the Creation of the connection. so any Idea of how to create the Map?

the getTypeMap returns an Empty map, and the javadoc says it will be empty till we set something to it.

any hints would be welcome.

Thanks in advance
Raj Chila
Ranch Hand

Joined: Mar 18, 2004
Posts: 128

Hi all,

I think I found a resource on this. thought it would be worthwhile to share it. we need to specify the key as a String, and then the type that we provide as the value should implement the SQLData Interface and put the pair into the Map...I noted that the JDBC specs suggest not to set a new Map Onject whic could possibly over write the existing mappings, rather to get the reference of the map through the getTypeMap and then add the new mappings to it and then set the type mapping to the connection using the setTypeMap method.

Hope this is informative to those interested.

Thanks any way...
Raj Chila
Ranch Hand

Joined: Mar 18, 2004
Posts: 128

Adding to the previous post...
...The above mentioned type mapping works only for the types that are defined in the database ( some user Defined Datatype... for example "Address" Type) and the key name has to be one that is defined in the database ("schemaname.type")
This is not what I was looking I guess we still have to look for a way to convert the Persistence Layer Datatypes to the SQL types.

so back to where I started
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33130

I don't know the answer to your question, but it I found your posts interesting to read.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: contents of Map Object in setTypeMap?
It's not a secret anymore!