My understanding is that this relationship between java.sql.Types and java types is defined in the jdbc spec. Is there a class where I can map a java.sql.Type to a java type? I am looking for a string if at all possible.
ex.. public String getJavaType(int sqlType)
Regards, Joshua
Wayne L Johnson
Ranch Hand
Joined: Sep 03, 2003
Posts: 399
posted
0
I don't believe that such a thing exists. The best you can do is look at the "java.sql.Types" API to see what's defined there. One of the difficulties in doing the mapping you propose is that there might not be one--and only one--way to map. For example, if something is "Numeric" in the database, should that to map to an "int", "long", "float", "double", "Integer", "Long", "Float" or "Double" in Java? I believe that the Java <--> Database type mapping is defined as a matrix of legal possibilities because there is no one-to-one mapping. [ October 29, 2003: Message edited by: Wayne L Johnson ]
The mappings for a specific database are usually in the database documentation. I've seen it for db2 and Oracle. Sun has a generic list that should apply to most databases. The exceptions would be in the database docs.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.