This discussion is archived
5 Replies Latest reply: Aug 3, 2010 8:48 AM by JackWang RSS

ORA-00932: inconsistent datatypes: expected MDSYS.SDO_GEOMETRY got CHAR

780862 Newbie
Currently Being Moderated
I am using Spring JDBC template in inserting into a table that has a SDO_GEOMETRY data type.

However, I am getting the following error:
ORA-00932: inconsistent datatypes: expected MDSYS.SDO_GEOMETRY got CHAR

-------------
Java,Spring
-------------
insertIntoTable.execute(map);

my map has the column, value key value pairs, and shown below is for the ADDRESS which is of SDO_GEOMETRY type:
parameters.put("ADDRESS ", "MDSYS.SDO_GEOMETRY(2001,8307,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1,1)," +
                    "MDSYS.SDO_ORDINATE_ARRAY("+getLongitude()+
                         ","+getLatitude()+" ))");


Did anyone have this problem before?

Thanks..
J
  • 1. Re: ORA-00932: inconsistent datatypes: expected MDSYS.SDO_GEOMETRY got CHAR
    Luc Van Linden Pro
    Currently Being Moderated
    You have to use JGeometry

    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14373/oracle/spatial/geometry/JGeometry.html

    and convert JGeometry instance to DB STRUCT

    PreparedStatement ps = conn.prepareStatement(sql);
    STRUCT obj = JGeometry.store(myPathGeom, conn);
    ps.setObject(1, obj);
    int recs = ps.executeUpdate();


    Here is one example:

    Re: Network.AddPaths

    Luc
  • 2. Re: ORA-00932: inconsistent datatypes: expected MDSYS.SDO_GEOMETRY got CHAR
    780862 Newbie
    Currently Being Moderated
    Thank you Luc.

    I have tried the following, and have received an error. I am debugging this:


    Tried this:
    JGeometry jGeom = new JGeometry(getLongitude(),lgetLatitude(),8307 );

    STRUCT dbObj = JGeometry.store(jGeom, this.getJdbcTemplate().getDataSource().getConnection());
    parameters.put("ADDRESS",dbObj);

    Got this error:
    java.lang.NoClassDefFoundError: oracle/sql/StructDescriptor
         at oracle.spatial.geometry.JGeometry.createDBDescriptors(JGeometry.java:1661)
         at oracle.spatial.geometry.JGeometry.store(JGeometry.java:1587)
         .....
    Caused by: java.lang.ClassNotFoundException: oracle.sql.StructDescriptor
         at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
         ... 23 more

    Looks like either a missing jar or a mismatched jar...

    Any ideas..
    Thank you
    J
  • 3. Re: ORA-00932: inconsistent datatypes: expected MDSYS.SDO_GEOMETRY got CHAR
    JackWang Pro
    Currently Being Moderated
    It looks like you are missing the ojdbc5.jar in your class path.

    jack
  • 4. Re: ORA-00932: inconsistent datatypes: expected MDSYS.SDO_GEOMETRY got CHAR
    780862 Newbie
    Currently Being Moderated
    Thank you for your reply Jack.

    I have placed the ojdbc6.jar. And I am getting the following error:
    Error:
    java.lang.ClassCastException: $Proxy0 cannot be cast to oracle.jdbc.OracleConnection
         at oracle.sql.StructDescriptor.createDescriptor(StructDescriptor.java:166)
         at oracle.sql.StructDescriptor.createDescriptor(StructDescriptor.java:137)
         at oracle.spatial.geometry.JGeometry.createDBDescriptors(JGeometry.java:1661)
         at oracle.spatial.geometry.JGeometry.store(JGeometry.java:1587)

    Code:
    JGeometry jGeom = new JGeometry(getLongitude(),getLatitude(),8307 );
    STRUCT dbObj = null;
    Connection con = null;//java.sql.Connection type
              try {
                   con = this.getJdbcTemplate().getDataSource().getConnection();
                   dbObj = JGeometry.store(jGeom, con);
                   parameters.put("ADDRESS",dbObj);
              } catch (SQLException e) {
                   e.printStackTrace();
              }

    I am using Spring jdbctemplate to get the connection and which is a proxy and is throwing an error.
    I wonder if JGeometry.store has a overloaded method that does not use connection.

    -J
  • 5. Re: ORA-00932: inconsistent datatypes: expected MDSYS.SDO_GEOMETRY got CHAR
    JackWang Pro
    Currently Being Moderated
    Hi,
    You might need to use an Oracle JDBC connection:
    String databaseUrl = jdbc:oracle:thin:@1.2.3.4:1521:yourdbname
    String databaseUser = dbusername
    String databasePassword = dbpassword
    DriverManager.registerDriver(new OracleDriver());
    Connection aConnection = DriverManager.getConnection(databaseUrl, databaseUser, databasePassword); 
    If you're implementing a java stored procedure, there is a default connection that is created for the session which is executing the Java stored procedure. You can use the connection in the JGeometry.store() method.
    Connection conn = null;
    try { conn = (Connection)DriverManager.getConnection("jdbc:default:connection:"); }
    catch(Exception e) { throw e; }
    Hope it helps!

    jack

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points