• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.sql.Type to java type mapping

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic