Menu

Change the mapping of datatypes for oracle db

Help
2009-02-02
2013-04-25
  • thomas blatt

    thomas blatt - 2009-02-02

    Hi,
    while generating the sql2java-classes for a oracle db, I got some datatype mappings which seems strange to me, f.e. the java-type java.lang.Object is generated for the db-type NVARCHAR2 which should be mapped into a java.lang.String.
    I'd like to configure the following mappings:

    NUMBER(10,0) --> Long
    NVARCHAR2 --> String

    Where and how can I change the dataype mappings?
    (I found the 3 examples for the DATE, TIME and TIMESTAMP mappings in the sql2java.properties, but can other types be mapped there too? How?)

    By the way: I found, that the generation results in other datatype mappings if I choose a MySQL DB ...

    greetings
    thomas

     
    • thomas blatt

      thomas blatt - 2009-02-03

      Hi,
      a additional info:
      it seems that sql2java don't knows the oracle datatype NVARCHAR2 wich results in the use of the mapping-rule for Types.OTHER (wich is java.lang.Object).

      How can I make sql2java know the type NVARCHAR2?

      grettings
      thomas

       
      • Alain Fagot Béarez

        The mappings between SQL types and Java types are defined in the code of class Column where in internal (sql2java specific) mapping type is used.

        sql2java/src/java/net/sourceforge/sql2java/Column.java

        My guess is that the whole mapping depends on the Java type returned by your driver.  Did you try with the driver provided with your Oracle version?  It seems to me that the classes12.jar distributed with sql2java is quite "obsolete" by now.

        Regards,
        Alain

         
    • Alain Fagot Béarez

      As far as the mapping of the NUMBER(10,0) to Long is concerned, I think the current code would do it, as long as your driver is returning a NUMERIC or DECIMAL as type for the column.

      Please try to get rid of the classes12.jar in the sql2java classpath and drop there your own driver for your version (not described in your post).  The classes12.jar was the driver for Oracle 9i.

      Regards,
      Alain

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.