Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.sql.Type to java type mapping

 
Joshua White
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34423
347
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This mapping tends to be database specific. What database are you using?
 
Joshua White
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mssql
Have you come across any resources that have mappings for the different databases?
Joshua
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34423
347
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic