• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 562
  • Last Modified:

How to map java.sql.types to Java classes?

Dear Experts,

I'm retrieving JDBC metadata, including java.sql.types, from a ResultSet.  Based on that, I need a factory method that will return the data from each column in a separate appropriate Java class.  For instance, a java.sql.Types.DECIMAL should be returned as a java.math.BigDecimal.  

Is anyone aware of an existing method that will do this for me?  At least, is there an existing Map representing which conversions should be done?

Thanks!
McJava1967
0
McJava1967
Asked:
McJava1967
1 Solution
 
CEHJCommented:
How would you use that btw?
0
 
McJava1967Author Commented:
It's a bit convoluted.  
I'm receiving a map of field names and values, and the name of a stored procedure.  I need to convert the map into parameters for the stored procedure.  But the values are all strings.  I need to pull the real types from the stored procedure (I have that worked out), and then cast those strings to an appropriate Java class.  Then I'll use a Spring StoredProcedure class to pass them in.
0
 
quincydudeCommented:
Hi, I do not know any mapping but just to help you by giving you more information about the matching types. You can have a look at the set methods in

http://java.sun.com/j2se/1.5.0/docs/api/java/sql/PreparedStatement.html

it lists the java equivalent of sql types. And hopefully you can create you own mapping afterwards.

Good luck!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now