Oracle sql STRUCT query

Hi all. I have a simple program running in JDeveloper using JDBC for retrieving SDO_Geometry values from various spatial tables. The program works fine but when I run the following SQL statement to retrieve the geometry column from a table states it is returning the sdo_geometry values in the following format:
spatialQuery = "select a.geom from states a";oracle.sql.STRUCT@e2dae9,     
oracle.sql.STRUCT@19209ea,     
oracle.sql.STRUCT@c8f6f8,     
oracle.sql.STRUCT@1ce2dd4,     
oracle.sql.STRUCT@122cdb6,     
I know the program works but can anyone tell me how to interpret these results or even how to translate them into a more useful format. Cheers Joe

I assume you are getting back a List (Vector) with the Struct inside it. Try ((List)query.getSingleResult()).get(0).
In JPA you should get the Struct back directly if the result size was 1, otherwise an Object[], this was a bug in EclipseLink 1.0 that was fixed in EclipseLink 1.1.
You should probably upgrade to EclipseLink 1.1.
James : http://www.eclipselink.org

Similar Messages

  • Oracle.sql.BLOB and oracle.sql.STRUCT

    I'm development a application in Java with oracle, to manage media files. When I try to insert into oracle , I have this problem "oracle.sql.BLOB cannot be cast to oracle.sql.STRUCT" , and I don't know what that can be ..
    This is my code , please help with that.. If you have a smaple code of java and oracle to insert media , that will be a great help ..
    public void loadDataFromStream(OracleConnection con)
    try {
    Statement s = con.createStatement();
    OracleResultSet rs = (OracleResultSet)
    s.executeQuery("select * from blobs where id='video2.avi' for update ");
    String index = "";
    while(rs.next())
    index = rs.getString(1);
    index+="1";
    System.out.println("llego hasta aki");
    // el error esta en esta linea de abajo ...
    OrdVideo vidObj = (OrdVideo) rs.getCustomDatum(2, OrdVideo.getFactory());
    //rs.getBfile(3);///
    FileInputStream fStream = new FileInputStream("/home/jova/movie.avi");
    vidObj.loadDataFromInputStream(fStream);
    vidObj.getDataInFile("/home/jova/movie.avi");
    fStream.close();
    System.out.println(" getContentLength output : " +
    vidObj.getContentLength());
    OraclePreparedStatement stmt1 =
    (OraclePreparedStatement) con.prepareCall("update blob_col set image = ? where id = " + index);
    stmt1.setCustomDatum(1,vidObj);
    stmt1.execute();
    stmt1.close() ;
    index+="1";
    System.out.println("OK");
    catch(Exception e) {
    System.out.println("exception raised " + e);
    System.out.println("load data from stream unsuccessful");
    }

    I'm development a application in Java with oracle, to manage media files. When I try to insert into oracle , I have this problem "oracle.sql.BLOB cannot be cast to oracle.sql.STRUCT" , and I don't know what that can be ..
    This is my code , please help with that.. If you have a smaple code of java and oracle to insert media , that will be a great help ..
    public void loadDataFromStream(OracleConnection con)
    try {
    Statement s = con.createStatement();
    OracleResultSet rs = (OracleResultSet)
    s.executeQuery("select * from blobs where id='video2.avi' for update ");
    String index = "";
    while(rs.next())
    index = rs.getString(1);
    index+="1";
    System.out.println("llego hasta aki");
    // el error esta en esta linea de abajo ...
    OrdVideo vidObj = (OrdVideo) rs.getCustomDatum(2, OrdVideo.getFactory());
    //rs.getBfile(3);///
    FileInputStream fStream = new FileInputStream("/home/jova/movie.avi");
    vidObj.loadDataFromInputStream(fStream);
    vidObj.getDataInFile("/home/jova/movie.avi");
    fStream.close();
    System.out.println(" getContentLength output : " +
    vidObj.getContentLength());
    OraclePreparedStatement stmt1 =
    (OraclePreparedStatement) con.prepareCall("update blob_col set image = ? where id = " + index);
    stmt1.setCustomDatum(1,vidObj);
    stmt1.execute();
    stmt1.close() ;
    index+="1";
    System.out.println("OK");
    catch(Exception e) {
    System.out.println("exception raised " + e);
    System.out.println("load data from stream unsuccessful");
    }

  • Oracle.sql.STRUCT

    Hi,
    when I use functions that returns a geometry (for example SDO_GOEM.SDO_BUFFER, SDO_GEOM.SDO_DIFFERENCE) I have in return oracle.sql.STRUCT@6c08b2..
    What can I do!?
    thanks

    as far as I know, the STRUCT is the returned geometry. so you can declare a SDO_GEOMETRY variable and assing the STRUCT directly to this variable.
    For example you have a variable 'geo_variable' and assign it the result of a function like this:
    geo_variable := SDO_GEOM.SDO_DIFFERENCE(geom1, geom2, tol );
    what you see written like this "oracle.sql.STRUCT@6c08b2.." I believe is the stuct @ the memory address 6c08b2..

  • Oracle.sql.STRUCT cannot be cast to oracle.sql.STRUCT

    I met a problem,I use oracle spatial to store geometry,then get it like this:
    STRUCT dbObject = (oracle.sql.STRUCT)rs.getObject("shape");
    JGeometry geom = JGeometry.load(dbObject);
    tomcat 6 told me java.lang.ClassCastException: oracle.sql.STRUCT cannot be cast to oracle.sql.STRUCT
    does everyone knows this problem?thanks
    Edited by: 811014 on 2010-11-13 下午9:28
    Edited by: 811014 on 2010-11-13 下午9:28

    Hi, this is a known problem for most Spatial 10g Java APIs with WLS.
    WLS is only certified with 11g DB.
    Instead of using Weblogic JNDI Lookup for Datasource, try the following snippet to create your connection/datasource (with Oracle JDBC thin driver):
    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);
    For more information, see the following:
    Classcast Exception while using Oracle ARRAYs
    regards,
    jack

  • Oracle.sql.STRUCT and returns from procedures

    I need to know how to retrieve information out of a stored procedure. I have a stored procedure that has a IN/OUT parameter that is used to return an array of an oracle TYPE that is set up in the database (it consists of two numbers and a varchar2. So I am returning an array of these types). I need to call this stored procedure from JDBC and retrieve the data out of it. I can setup the outParameter of the statement and also get the Object out of the statement once the procedure is called. But what is returned to me? An array of oracle.sql.STRUCT objects? A single oracle.sql.STRUCT object? A multi-dimensional array of java objects? Or something else?
    Thanks
    null

    as far as I know, the STRUCT is the returned geometry. so you can declare a SDO_GEOMETRY variable and assing the STRUCT directly to this variable.
    For example you have a variable 'geo_variable' and assign it the result of a function like this:
    geo_variable := SDO_GEOM.SDO_DIFFERENCE(geom1, geom2, tol );
    what you see written like this "oracle.sql.STRUCT@6c08b2.." I believe is the stuct @ the memory address 6c08b2..

  • How to tune the performance of Oracle SQL/XML query?

    Hi all,
    I am running Oracle 9i and like to run the following Oracle SQL/XML query. It takes about 3+ hour and still not finish. If I get rid all the XML stuffs it only take minutes to run. Does anybody know how to what's the reason of this slow and how to tune it?
    SELECT XMLElement("CUSTOMER",
    XMLForest(C_CUSTKEY "C_CUSTKEY", C_NAME "C_NAME", C_ADDRESS "C_ADDRESS", C_PHONE "C_PHONE", C_MKTSEGMENT "C_MKTSEGMENT", C_COMMENT "C_COMMENT"),
    (SELECT XMLAgg(XMLElement("ORDERS",
    XMLForest(O_ORDERKEY "O_ORDERKEY", O_CUSTKEY "O_CUSTKEY", O_ORDERSTATUS "O_ORDERSTATUS", O_ORDERPRIORITY "O_ORDERPRIORITY", O_CLERK "O_CLERK", O_COMMENT "O_COMMENT"),
    (SELECT XMLAgg(XMLElement("LINEITEM",
    XMLForest(L_ORDERKEY "L_ORDERKEY", L_RETURNFLAG "L_RETURNFLAG", L_LINESTATUS "L_LINESTATUS", L_SHIPINSTRUCT "L_SHIPINSTRUCT", L_SHIPMODE "L_SHIPMODE", L_COMMENT "L_COMMENT")
    FROM LINEITEM
    WHERE LINEITEM.L_ORDERKEY = ORDERS.O_ORDERKEY)
    FROM ORDERS
    WHERE ORDERS.O_CUSTKEY = CUSTOMER.C_CUSTKEY)
    FROM CUSTOMER ;
    Thanks very much in advance for your time,
    Jinghao Liu

    ajallen wrote:
    Why not something more like
    SELECT *
    FROM fact1 l,
    FULL OUTER JOIN fact1 d
    ON l.company = d.company
    AND l.transactiontypeid = 1
    AND d.transactiontypeid = 2;
    Because this is not an equivalent of the original query.
    drop table t1 cascade constraints purge;
    drop table t2 cascade constraints purge;
    create table t1 as select rownum t1_id from dual connect by level <= 5;
    create table t2 as select rownum+2 t2_id from dual connect by level <= 5;
    select * from (select * from t1 where t1_id > 2) t1 full outer join t2 on (t1_id = t2_id);
    select * from t1 full outer join t2 on (t1_id = t2_id and t1_id > 2);
         T1_ID      T2_ID
             3          3
             4          4
             5          5
                        6
                        7
         T1_ID      T2_ID
             1
             2
             3          3
             4          4
             5          5
                        6
                        7

  • How to perf tune Oracle SQL/XML query?

    Hi all,
    I am using Oracle 9i and like to run the following Oracle SQL/XML query. It takes about 3+ hour and still not finish. If I get rid all the XML stuffs it only take minutes to run. Does anybody know how to what's the reason of this slow and how to tune it?
    SELECT XMLElement("CUSTOMER",
    XMLForest(C_CUSTKEY "C_CUSTKEY", C_NAME "C_NAME", C_ADDRESS "C_ADDRESS", C_PHONE "C_PHONE", C_MKTSEGMENT "C_MKTSEGMENT", C_COMMENT "C_COMMENT"),
    (SELECT XMLAgg(XMLElement("ORDERS",
    XMLForest(O_ORDERKEY "O_ORDERKEY", O_CUSTKEY "O_CUSTKEY", O_ORDERSTATUS "O_ORDERSTATUS", O_ORDERPRIORITY "O_ORDERPRIORITY", O_CLERK "O_CLERK", O_COMMENT "O_COMMENT"),
    (SELECT XMLAgg(XMLElement("LINEITEM",
    XMLForest(L_ORDERKEY "L_ORDERKEY", L_RETURNFLAG "L_RETURNFLAG", L_LINESTATUS "L_LINESTATUS", L_SHIPINSTRUCT "L_SHIPINSTRUCT", L_SHIPMODE "L_SHIPMODE", L_COMMENT "L_COMMENT")
    FROM LINEITEM
    WHERE LINEITEM.L_ORDERKEY = ORDERS.O_ORDERKEY)
    FROM ORDERS
    WHERE ORDERS.O_CUSTKEY = CUSTOMER.C_CUSTKEY)
    FROM CUSTOMER ;
    Thanks very much in advance for your time,
    Jinghao Liu

    Please post this message at:
    Forums Home » Oracle Technology Network (OTN) » Products » Database » XML DB

  • Java.lang.NoClassDefFoundError: oracle/sql/STRUCT after 11g/GF3.1.2 upgrade

    We have recently upgraded all of our servers from:
    Java 1.6.31 to 1.6.32
    and
    Glassfish 3.1.1 to 3.1.2
    We upgraded our development server from Oracle 10g to 11g.
    Our live servers are working fine. Our development server now is spewing out a java.lang.NoClassDefFoundError: oracle/sql/STRUCT error whenever it encounters a servlet or page which uses this class.
    ojdbc14.jar and sdopai.jar were included within the WAR file, and I have tried with them excluded from the WAR file to no avail. We have tried reverting the version of ojdbc.jar on the server to the earlier version, this has made no different.
    Any ideas? The full stack trace is below:
    [#|2012-05-28T16:15:34.950+0100|WARNING|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=80;_ThreadName=Thread-2;|StandardWrapperValve[EnterDataSS]: PWC1406: Servlet.service() for servlet EnterDataSS threw exception
    java.lang.NoClassDefFoundError: oracle/sql/STRUCT
    at oracle.spatial.geometry.JGeometry.load(JGeometry.java:3097)
    at Bto.Location.LocatorUtils.JavaScriptifySDO(LocatorUtils.java:97)
    at Bto.Chats.Controllers.EnterDataModuleMain.<init>(EnterDataModuleMain.java:136)
    at Bto.Chats.SessionBean.initialiseEdm2(SessionBean.java:348)
    at Bto.Chats.Servlets.Enter.EnterDataSS.processRequest(EnterDataSS.java:36)
    at Bto.Chats.Servlets.ChatsServlet.doGet(ChatsServlet.java:90)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
    at com.sun.grizzly.http.ajp.AjpProcessorTask.invokeAdapter(AjpProcessorTask.java:135)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:662)
    Caused by: java.lang.ClassNotFoundException: oracle.sql.STRUCT
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 33 more
    |#]

    >
    Our live servers are working fine. Our development server now is spewing out a java.lang.NoClassDefFoundError: oracle/sql/STRUCT error whenever it encounters a servlet or page which uses this class.
    ojdbc14.jar and sdopai.jar were included within the WAR file, and I have tried with them excluded from the WAR file to no avail. We have tried reverting the version of ojdbc.jar on the server to the earlier version, this has made no different.
    >
    If your code can't find the class then you have the classic NoClassDefFoundError problem you get when any other referenced class can't be located.
    The oracle/sql/STRUCT class is in the ojdbc14.jar, ojdbc5.jar and ojdbc6.jar so if it can't be found then that class is missing from the jar you are using (which you can tell by examining the jar contents) or the jar is missing from the classpath being used.
    As already mentioned you need the Oracle 11 JDBC files to support Java 1.6
    Here is the official Oracle JDBC page that shows the Oracle DB versions supported for each of the JDBC drivers available and also describes the JDBC jars and what JDK versions they support.
    http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-faq-090281.html#02_01
    >
    Which JDBC drivers support which versions of Javasoft's JDK?
    pre-8i OCI and THIN Drivers - JDK 1.0.x and JDK 1.1.x
    8.1.5 OCI and THIN Drivers - JDK 1.0.x and JDK 1.1.x
    8.1.6SDK THIN Driver - JDK 1.1.x and JDK 1.2.x (aka Java2)
    8.1.6SDK OCI Driver - Only JDK 1.1.x
    8.1.6 OCI and THIN Driver - JDK 1.1.x and JDK 1.2.x
    8.1.7 OCI and THIN Driver - JDK 1.1.x and JDK 1.2.x
    9.0.1 OCI and THIN Driver - JDK 1.1.x, JDK 1.2.x and JDK 1.3.x
    9.2.0 OCI and THIN Driver - JDK 1.1.x, JDK 1.2.x, JDK 1.3.x, and JDK 1.4.x
    10.1.0 OCI and THIN Driver - JDK 1.2.x, JDK 1.3.x, and JDK 1.4.x
    10.2.0 OCI and THIN Driver - JDK 1.2.x, JDK 1.3.x, JDK 1.4.x, and JDK 5.0.x
    11.1.0 OCI and THIN Driver - JDK 1.5.x and JDK 1.6.x
    11.2.0 OCI and THIN Driver - JDK 1.5.x and JDK 1.6.x
    Please note that JDK 1.4 is not supported by the 11 drivers.

  • Obtaining an oracle.sql.STRUCT through a pooled JDBC connection

    Hello,
    I am using WebLogic Server 10 and and Oracle 10 and I am trying to obtain a vendor-specific oracle.sql.STRUCT from a ResultSet using a pooled connection defined in Weblogic. I need the vendor-specific object, rather than simply the java.sql.Struct implementation, because a third party library requires it.
    What gets returned in the ResultSet is a non-exposed WebLogic wrapper object which implements java.sql.Struct, but which cannot be cast to an oracle.sql.STRUCT. I can use reflection on this object to find and call the getVendorObj() method to obtain the oracle.sql.STRUCT, but this solution is not acceptable because this is not a published API and is not guaranteed not to change in future versions.
    How can I reliably obtain a vendor-specific implementation of java.sql.Struct through a WebLogic connection pool in WebLogic Server 10?
    Thanks for any advice,
    -Dan Schwemlein

    dan schwemlein wrote:
    Joe,
    Thanks again. With your guidance, I have arrived at the following approach, which I'll post for the benefit of others, and which I'd be thankful if you would validate:
    1) Import the jar com.bea.core.datasource-1.0.0.0.jar from %BEA_HOME%\modules, which is the only location of the class WLConnection, which is the only class with the getVendorConnection() method you refer to.
    2) Get the logical connection from the pooled data source, cast it to a WLConnection, call getVendorConnection() to obtain an OracleConnection (from the ojdbc jar), and use this connection to obtain the required oracle.sql.STRUCT from an OracleResultSet.
    3) Be aware of the limitations and follow the guidelines in the document http://e-docs.bea.com/wls/docs81/jdbc/thirdparty.html#1043646 regarding security, error handling, releasing resources (close only the logical connection), etc.
    Does this sound like the approach you had in mind?
    Thanks again,
    -Danyes.
    Joe
    >
    Re: Obtaining an oracle.sql.STRUCT through a pooled JDBC connection
    Posted: Jul 16, 2007 3:21 PM
    dan schwemlein wrote:
    Thanks for the quick response!I was working today...
    Thank you for the information about the connection being closed.
    I will look into using this configuration setting.
    You say that you can describe a way to get a handle on an unwrapped
    pool object using some documented WLS-specific code. Are you referring
    here to the getVendorConnection() method?yes.
    This method does not help me
    get the oracle.sql.STRUCT object, because even the connection returned
    by getVendorConnection() returns a wrapped WL java.sql.Struct object
    from a call to getObject().I don't believe it. If you are running in WLS, with a local pool,
    the getVendorConnection() will give you the Oracle connection,
    which will give you an Oracle statement, etc, down to an oracle
    STRUCT object. Once you have a direct reference to the oracle connection,
    we're not in the picture when it returns something to you.
    It would be great if getVendorObj() were
    documented and could be counted on in future versions. To use this
    method, one would still have to access it via Java reflection, because
    the wrapper class and its getVendorObj() method would be exposed in an
    API, correct? Could this method be exposed in the API, so that reflection
    doesn't need to be used, or it is exposed somewhere that isn't documented?getVendorObj() is not yet exposed or therefore supported for the general
    wrapped object, so you would have to start from the connection and
    derive all subobjects from it.
    Thanks again,
    -Dan Schwemlein
    Hello,
    I am using WebLogic Server 10 and and Oracle 10 and I am trying to obtain a
    vendor-specific oracle.sql.STRUCT from a ResultSet using a pooled connection
    defined in Weblogic. I need the vendor-specific object, rather than simply
    the java.sql.Struct implementation, because a third party library requires it.
    What gets returned in the ResultSet is a non-exposed WebLogic wrapper object
    which implements java.sql.Struct, but which cannot be cast to an oracle.sql.STRUCT.
    I can use reflection on this object to find and call the getVendorObj() method to
    obtain the oracle.sql.STRUCT, but this solution is not acceptable because this is
    not a published API and is not guaranteed not to change in future versions.Understood. We all benefit from sticking to the J2EE standards,
    but we could also wish Oracle had done so with it's driver objects.
    I will assume your code is running in the WebLogic server, because
    an external JVM can never access the real driver object, which will
    always really be in the WLS JVM. No active JDBC object is serializable.
    How can I reliably obtain a vendor-specific implementation of java.sql.Struct
    through a WebLogic connection pool in WebLogic Server 10?There is no way to get a handle on an unwrapped pool object without using some
    WLS-specific code, though I can describe a way with documented methods,
    and/or I can get our documentation altered to say we'll support the
    getVendorObj() method. We introspect every vendor object, and for those
    implementations that have done the wise thing, projecting any non-standard
    methods as an Interface, we are able to also project that Interface so
    the vndor example code should work. However, in some poorly-done
    cases, such as for some Oracle stuff, there is either no Interface,
    or the Oracle code has extensions that take java.sql objects as input,
    (at least that's the signature of the method) but two lines into the
    method, the Oracle code assumes and casts the java.sql object to a concrete
    Oracle object. In these use cases you need the direct unwrapped object.
    We provide and document Connection.getVendorConnection(), and intend
    getVendorObj() to serve the same for subobjects, but note the dangers
    and responsibilities: We rely on our wrappers to implement the security
    and thread-safety of our pooling system. Because user code can get
    unrestricted access to the actual connection from most JDBC objects,
    we can never trust that we have complete control once a vendor object
    is exposed. Therefore, by default we will close and replace every JDBC
    connection so exposed, as soon as the current thread is finished with
    the pool connection. This hurts performance. We also document a pool
    config setting that will tell us that you take responsibility for any such
    problems, and not to close connections just because they've been exposed.
    HTH,
    Joe
    Thanks for any advice,
    -Dan Schwemlein

  • Using oracle.sql.STRUCT to pass in a COMPLEX OBJECT

    I need to pass in a complex object (object with nested array of objects) into a oracle stored procedure.
    We are using JDBC 9.2.0.1 drivers...
    Note i am able to retrieve a complex object successfully using an oracle struct however i am not able to pass in the struct.
    I do not want to use JPublisher as we are not using SQLJ.
    I have looked through the documentation on using default structs and am getting an error when i try and create the struct...
    I have created an array of objects with a sub array
    and i create a struct descriptor however when i create the actual oracle struct
    like
    oracle.sql.Struct = new oracle.sql.Struct( structDesc,conn,complexobject)
    I get a "java.sql.SQLException: Internal Error: Unable to resolve name"
    Do i have to create STRUCTS for the nested object first ?
    And then nest that STRUCT within the PARENT STRUCT to pass in complex objects ???
    Any help would be much appreciated...
    Gurinder
    email [email protected]

    Thanks Konstantin Goryachev!
    I'm using Oracle JDBC 9.2.0.3 drivers using a SQLData implementation.
    Unfortunately i have something very similar to your code and i still get the following error
    EXC: testPolicyRate(): java.sql.SQLException: Internal Error: Inconsistent catalog view
    java.sql.SQLException: Internal Error: Inconsistent catalog view
         void oracle.jdbc.dbaccess.DBError.throwSqlException(java.lang.String, java.lang.String, int)
              DBError.java:187
         void oracle.jdbc.dbaccess.DBError.throwSqlException(int, java.lang.Object)
              DBError.java:229
         void oracle.sql.StructDescriptor.initMetaData1_9_0()
              StructDescriptor.java:897
         void oracle.sql.StructDescriptor.initMetaData1()
              StructDescriptor.java:864
         boolean oracle.sql.StructDescriptor.isInstantiable()
              StructDescriptor.java:508
         void oracle.sql.STRUCT.<init>(oracle.sql.StructDescriptor, java.sql.Connection, java.lang.Object[])
              STRUCT.java:107
         oracle.sql.STRUCT oracle.sql.OracleSQLOutput.getSTRUCT()
              OracleSQLOutput.java:96
         oracle.sql.STRUCT oracle.sql.STRUCT.toSTRUCT(java.lang.Object, oracle.jdbc.OracleConnection)
              STRUCT.java:408
         oracle.sql.Datum oracle.jdbc.oracore.OracleTypeADT.toDatum(java.lang.Object, oracle.jdbc.driver.OracleConnection)
              OracleTypeADT.java:284
         oracle.sql.Datum[] oracle.jdbc.oracore.OracleTypeADT.toDatumArray(java.lang.Object, oracle.jdbc.driver.OracleConnection, long, int)
              OracleTypeADT.java:327
         oracle.sql.Datum[] oracle.jdbc.oracore.OracleTypeUPT.toDatumArray(java.lang.Object, oracle.jdbc.driver.OracleConnection, long, int)
              OracleTypeUPT.java:143
         oracle.sql.Datum[] oracle.sql.ArrayDescriptor.toOracleArray(java.lang.Object, long, int)
              ArrayDescriptor.java:771
         void oracle.sql.ARRAY.<init>(oracle.sql.ArrayDescriptor, java.sql.Connection, java.lang.Object)
              ARRAY.java:118
         void com.tu.lib.busobject.PolicyRate.main(java.lang.String[])
              PolicyRate.java:198
    Process exited with exit code 0.
    Here's my code
    * Main Method
    public static void main(String[] args)
    throws SQLException, IOException
    Connection conn = null;
    OracleCallableStatement cstmt = null;
    try {
    /* Setup connection */
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    conn = DriverManager.getConnection("jdbc:oracle:thin:@neptune:1521:tu_test", "OPS$WWW", "welcome1");
    conn.setAutoCommit(false);
    System.out.println("conn is open = " + !conn.isClosed());
    /* Setup map */
    System.out.println("Creating type maps...");
    java.util.Map typeMap = conn.getTypeMap();
    typeMap.put(_SQL_NAME,PolicyRate.class);
    typeMap.put(CoverageRate._SQL_NAME, CoverageRate.class);
    typeMap.put(CoverageRate._SQL_ARRAY_NAME,CoverageRate[].class);
    conn.setTypeMap(typeMap);
    /* Create a coverage rate object to be inserted into array of policy rate object */
    CoverageRate covrObj = new CoverageRate(1,
    "HMS",
    30,
    5,
    new BigDecimal(0),
    null,
    null,
    new BigDecimal(0),
    new BigDecimal(0),
    0,
    0);
    /* Create an array */
    System.out.println("Creating descriptor...");
    ArrayDescriptor adesc = new ArrayDescriptor(CoverageRate._SQL_ARRAY_NAME,conn);
    System.out.println("Created descriptor!");
    Object [] covrArray = new Object[1];
    covrArray[0] = covrObj;
    System.out.println("Creating oracle array..");
    ARRAY arr = new ARRAY(adesc,conn,covrArray);
    System.out.println("Created array!!");
    /* Create policy rate object */
    PolicyRate prate = new PolicyRate ("TESTTRA",
    "TRS",
    TUDate.convertToSql("2003","08","27"),
    TUDate.convertToSql("2004","06","25"),
    TUDate.convertToSql("2004","06","29"),
    "NEW",
    1,
    new BigDecimal(0),
    new BigDecimal(0),
    null);
    /* Add coverage rate object to array -- assume array only has one element for timebeing */
    System.out.println("Setting arr in policyrate...");
    prate.setRates(arr);
    System.out.println("Creating array.sql.ARRAY for covrObj..");
    prate.setRates(new oracle.sql.ARRAY(adesc,conn,covrObj));
    System.out.println("Created array.sql.ARRAY for covrObj..");
    /* Setup statemenet object */
    cstmt = (OracleCallableStatement) conn.prepareCall("{call dbpckg_rate_obj.p_rate_obj_calc_rate(?)}");
    /* Bind variables to statement */
    System.out.println("Setting policyrate object...");
    cstmt.setObject(1,prate,OracleTypes.STRUCT);
    System.out.println("Registering out object...");
    cstmt.registerOutParameter(1,oracle.jdbc.OracleTypes.STRUCT,PolicyRate._SQL_NAME);
    cstmt.execute();
    /* Retrieve the object back */
    System.out.println("Getting policy rate object back...");
    prate = (PolicyRate) cstmt.getObject(1);
    System.out.println("Object Retrieved " + prate.getProductcode() + " " + prate.getAgentcode());
    /* Close database connection */
    conn.close();
    catch (Exception exc) {
    System.out.println("EXC: testPolicyRate(): " + exc);
    exc.printStackTrace();
    if (conn != null)
    conn.close();
    finally {     
    if (conn != null)
    conn.close();
    I've opened up a tar through metalink hopefully they can help get past this error...:)
    Gurinder

  • Oracle SQL Select query takes long time than expected.

    Hi,
    I am facing a problem in SQL select query statement. There is a long time taken in select query from the Database.
    The query is as follows.
    select /*+rule */ f1.id,f1.fdn,p1.attr_name,p1.attr_value from fdnmappingtable f1,parametertable p1 where p1.id = f1.id and ((f1.object_type ='ne_sub_type.780' )) and ( (f1.id in(select id from fdnmappingtable where fdn like '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#%')))order by f1.id asc
    This query is taking more than 4 seconds to get the results in a system where the DB is running for more than 1 month.
    The same query is taking very few milliseconds (50-100ms) in a system where the DB is freshly installed and the data in the tables are same in both the systems.
    Kindly advice what is going wrong??
    Regards,
    Purushotham

    SQL> @/alcatel/omc1/data/query.sql
    2 ;
    9 rows selected.
    Execution Plan
    Plan hash value: 3745571015
    | Id | Operation | Name |
    | 0 | SELECT STATEMENT | |
    | 1 | SORT ORDER BY | |
    | 2 | NESTED LOOPS | |
    | 3 | NESTED LOOPS | |
    | 4 | TABLE ACCESS FULL | PARAMETERTABLE |
    |* 5 | TABLE ACCESS BY INDEX ROWID| FDNMAPPINGTABLE |
    |* 6 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
    |* 7 | TABLE ACCESS BY INDEX ROWID | FDNMAPPINGTABLE |
    |* 8 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
    Predicate Information (identified by operation id):
    5 - filter("F1"."OBJECT_TYPE"='ne_sub_type.780')
    6 - access("P1"."ID"="F1"."ID")
    7 - filter("FDN" LIKE '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#
    8 - access("F1"."ID"="ID")
    Note
    - rule based optimizer used (consider using cbo)
    Statistics
    0 recursive calls
    0 db block gets
    0 consistent gets
    0 physical reads
    0 redo size
    0 bytes sent via SQL*Net to client
    0 bytes received via SQL*Net from client
    0 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    9 rows processed
    SQL>

  • Problems retreiving varchar attributs from oracle.sql.STRUCT

    Hi,
    I have downloaded the Java + Oracle Object Types examples from the oracle homepage, but instead of the varchar values from a STRUCT the Java-application just displays "???". Numbers and dates are displayed correct.
    Im running JDK1.4 on Windows and Oracle 9.2.0.8 on Unix with corresponding JDBC driver
    Any idea?
    Thanx in advance,
    Jo

    Jo,
    I'm guessing it has something to do with your NLS / I18N settings.
    Do you know what they are?
    Usually, both JDK and Oracle assume an American environment.
    In other words, American English, etc.
    Is your environment different to this?
    Good Luck,
    Avi.

  • Oracle.sql.* with JDBC drivers 8.0.5

    the oracle.sql package is not included in my JDBC driver file classes111.zip given for oracle data server version 8.0.5.
    I would like to use the oracle STRUCT and ARRAY type for calling PL/SQL stored procedures taking STRUCT objects in arguments.
    Are the JDBC drivers 8.1.* compatible with the oracle data server 8.0.5 (if I only use the STRUCT or ARRAY types)? Is it a way for passing ARRAY of VARCHAR2 values to PL/SQL stored procedure with the oracle 8.0.5 JDBC driver?
    thanks

    Unfortunately, these classes (oracle.sql.STRUCT and oracle.sql.ARRAY) are not compatible to 8.0 database. There is server format changes between 8.1 and 8.0, and JDBC driver only supports the 8.1 format.
    Please upgrade your database to 8i.

  • Get only last level in SQL Hierarchy Query

    Hi,
    How to get only the last level in Oracle SQL Hierarchy Query?
    Thanks

    Hi,
    1007372 wrote:
    Hi,
    How to get only the last level in Oracle SQL Hierarchy Query?Depending on your requirements:
    WHERE   CONNECT_BY_ISLEAF  = 1 
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    If you can show what you want to do using commonly available tables (such as scott.emp, which contains a hierarchy), then you don't need to post any sample data; just the results and the explanation.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0). This is always important, but especially so with CONNECT BY queries, because every version since Oracle 7 has had significant improvements in this area.
    See the forum FAQ {message:id=9360002}

  • Fail to convert to internal representation: oracle.sql.DATE

    I'm using the oracle 8.1.7 jdbc driver against oracle 8.1.7 running on NT, and I get the exception message below when I attempt to insert an jpub object structure into a prepared statement.
    All date objects have been constructed from a timestamp object, using the oracle.sql.DATE Timestamp constructor. So I'm surprised to get this error given the timestamp object was successfully constructed.
    I've tried session date formats of 'yyyy-mm-dd hh24:mi:ss' and 'mm/dd/yyyy hh24:mi:ss', with no success.
    I can call stringValue on oracle.sql.DATE and it returns a valid date.
    Can someone confirm that they have been able to use the oracle.sql.DATE class to insert a date correctly into the database? Its seems a silly question to ask but you have to start somewhere!
    Exception : Fail to convert to internal representation: oracle.sql.DATE@3c144e8a
    Stack trace : java.sql.SQLException: Fail to convert to internal representation: oracle.sql.DATE@3c144e8a
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
    at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:829)
    at oracle.jdbc.oracore.OracleTypeADT.toDatum(OracleTypeADT.java:261)
    at oracle.sql.StructDescriptor.toOracleArray(StructDescriptor.java:385)
    at oracle.sql.StructDescriptor.toArray(StructDescriptor.java:560)
    at oracle.sql.STRUCT.<init>(STRUCT.java:95)
    at oracle.jpub.runtime.MutableStruct.toDatum(MutableStruct.java:65)
    null

    The JPub/JDBC runtime is converting your Java object into Oracle-specific representation (all data is put in oracle.sql.XXXX format). The top level object is an oracle.sql.STRUCT, the attributes of which are represented as an array of oracle.sql.Datum objects - in your case an oracle.sql.NUMBER and an oracle.sql.DATE. However, the error does occur in the StructDescriptor which describes the SQL type and the shape of the object. Is the error dependent on the data values? Might null values not be dealt with, correctly?
    One thing to try to do is create such an oracle.sql.STRUCT object from scratch with the same attribute values and insert/manipulate that using SQL.
    I have not dealt with TAR's. If you send me a self-contained test case, I'll check it against the current development version of JDBC. (At least you'll know if the next JDBC release fixes this issue :-) I might also file a bug.

Maybe you are looking for

  • After updating to Firefox 3.6.13 saved passwords no longer work

    Prior to updating to 3.6.13 saved usernames and passwords worked as they should (those fields were automatically filled in). Now after installing 2.6.13 most saved login info will not fill in upon entering the web site. I can go to tools, options, se

  • DVD Burn Failed-Matshita DVD-R UJ-815

    Please help: I can not burn any DVDs. I am trying to burn some pictures from iPhoto to DVD for storage. I choose the pictures & then hit the burn icon at the bottom of iPhoto. It will run for about an hour but then stops. I keep getting "Burn Failed:

  • Toshiba 20AF45 has Black/White Picture

    Hello I have a Toshiba 20af45 TV that is not showing the picture in color. I have both a 3 color av cord and the 5 color one. I've tried to see if I can change it in the menu settings but there is no av input button. The menu under colorstream only a

  • HELP - My Battery is either magical, or is about to explode.

    So ive been noticing that ive been getting horrrible battery life (usually just over an hour) on my macbook, even when not doing much on it. So just this afternoon i decided to calibrate it. So i used my computer normally until the battery went out a

  • I keep getting kernel panics, is it the airport?

    Here's my log: Tue Nov 18 10:58:20 2008 panic(cpu 1 caller 0x001A8CEC): Kernel trap at 0x008ce953, type 0=divide error, registers: CR0: 0x8001003b, CR2: 0xb031c00c, CR3: 0x00fa0000, CR4: 0x00000660 EAX: 0x000000df, EBX: 0x00000010, ECX: 0x00000000, E