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

Posted on 2008-11-12
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?

Question by:McJava1967
    LVL 86

    Expert Comment

    How would you use that btw?

    Author Comment

    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.
    LVL 15

    Accepted Solution

    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

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

    Good luck!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
    For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
    Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

    758 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

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now