[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2008-11-12
3
Medium Priority
?
557 Views
Last Modified: 2012-08-14
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
Comment
Question by:McJava1967
3 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 22941491
How would you use that btw?
0
 

Author Comment

by:McJava1967
ID: 22941739
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
 
LVL 15

Accepted Solution

by:
quincydude earned 2000 total points
ID: 22948322
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month17 days, 20 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question