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");
}

Similar Messages

  • 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..

  • 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..

  • 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 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

  • 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

  • Create Oracle BLOB and Pass to Oracle Stored Procedure

    Hi All,
    I am using Oracle 10g and am dealing with a requirement where I have to upload a file to Oracle Portal from the client's local machine using a JSP.
    I am planning to convert the text file to a BLOB and pass it to an Oracle stored procedure which does the rest.
    I am unable to create a BLOB object. Can anybody help me with this please.
    Is there a better alternative to do it?
    Thanks in advance,
    Shardul

    u can create blob as below...
    java.sql.Blob blob=new Blob();
    File file=new File(fullPathTo UrFile);
    FileInputStream fInSteam = new FileInputStream(file);
    BufferedInputStream bInputStream = new BufferedInputStream(fInSteam);
    ByteArrayOutputStream bOutputStream = new ByteArrayOutputStream();
    int nextByte;
    while (( nextByte = bInputStream.read() ) != - 1)
    bOutputStream.write(nextByte);
    byte[] byteContent = bOutputStream.toByteArray();
    blob.setBytes(byte[]);
    i think it should work for u...

  • Help required in handling of Oracle BLOB and CLOB in OC4J

    Hi,
    I am in a process of porting my application from Weblogic 6 to OC4J.
    I have problem while handling CLob and Blob's in oracle. Weblogic has
    classes defined to do the same. (weblogic.jdbc.common.OracleClob)
    Does any one know how I can achieve this.
    Thanks in advance.
    Regards,
    Moin

    We have an application running on OC4J accessing an Oracle 8.1.7 db, and have no problems using BLOBs and CLOBs. It is explained quite clearly in the Oracle documentation.
    If you require further assistance let me know :-)

  • Blobs and sql

    i was given a new task at work today and it involves automating datbase results. We are given one record and i have to populate the rest of the database to a given amount of records.
    i have this blob and i know its an image and i am trying to retrieve it but the getBlob() is giving me an error. I hope someone can help me.

    It looks like I have to resort to using an OCIBlobLocator
    as I would if not using ANSI Dynamic. I guess I assumed that
    since I specify the exact amount I want out and the type to be
    raw I wouldn't need the lob-locator. Can anyone tell me why
    the code fragment below seg faults rather than returns some
    ora/sql error?
    I'm trying to retrieve a blob using ANSI Dynamic SQL in a Pro*C application.
    However, when I attempt to use FETCH DESCRIPTOR I get a segmentation fault.
    The precompiler picks up if the fetch size and the output structure size
    don't match, but it seems that they don't actually match according to the
    database.
    char correctedinb[GAMMA_CHANNELS*4];
    rtype = 113;
    rsize = GAMMA_CHANNELS*4;
    EXEC SQL SET DESCRIPTOR :out_desc VALUE :occurs
    TYPE = :rtype,
    LENGTH = :rsize,
    REF DATA = :correctedinb,
    REF INDICATOR = :spectrumind;
    occurs++;
    EXEC SQL FETCH g INTO DESCRIPTOR :out_desc;

  • Overhead of using java.sql.STRUCT

    I am calling a stored proc passing in a java.sql.STRUCT
    created via DDL statement
    CREATE TYPE APPDBA.MY_STRUCT
    AS OBJECT
    USER_KEY INTEGER,
    USER_HOME VARCHAR2(32)
    My question is:
    when i am creating a structdescriptor from java
    oracle.sql.StructDescriptor sDesc =
    oracle.sql.StructDescriptor.createDescriptor ("APPDBA.MY_STRUCT", mConnection)
    what exactly goes on under the hood here? Does the driver
    make a round trip call to the DB every time?
    Does it do some sort of caching?
    Thanks.

    Thanks for your reply. But please take a look at the following code snippet. It intends to add a Timestamp representing the
    start of a day (time component 00:00:00) to a time component (having Date to 01-01-1970):
            Time time = new Time(61952000);
            Calendar c = Calendar.getInstance();
            System.out.println("time: " + time); // 18:12:32
            c.set(Calendar.HOUR_OF_DAY, 0);
            c.set(Calendar.SECOND, 0);
            c.set(Calendar.MINUTE, 0);
            c.set(Calendar.MILLISECOND, 0);
            System.out.println("date: " + c.getTime()); // Fri Apr 03 00:00:00 CEST 2009
            Timestamp timestamp = new Timestamp( c.getTimeInMillis() + time.getTime() );
            Date d = new Date(timestamp.getTime() );
            System.out.println("\nresult: " + d); // result: Fri Apr 03 17:12:32 CEST 2009If I assume that getting and setting the milis always deals with timezone independent values, but operating methods
    like toString(), getHour() etc use the timezone, then I can not explain the result (last line): 17:12:32 is the timezone
    independend value. Should'nt d.toString() show the timezone dependend value of 18:12:32?

  • Migrating LONG RAW to BLOB and optimizing extent size

    Hi all,
    I got a quite fragmented table with a LONG RAW column I want to migrate to BLOB and defragment.
    DB version is Oracle9i Release 9.2.0.4.0 and this is a production environment.
    I know MOVE and/or CTAS are not possible with LONG RAW columns
    So, how can I do that? Is ALTER TABLE MODIFY the only possibility to migrate from LOING RAW to BLOB?
    Since ALTER TABLE MODIFY will lock the whole table preventing any DML operation, I need at least a rough estimate of the time needed for this operation. How can I do that?
    Since this table is quite fragmented, I also want to rebuilt it using a different extent size.
    I think I should issue a ALTER TABLE MOVE... after having performed the "ALTER TABLE MODIFY".
    Can I do something better to minimize unavailability to DML operations?
    thanks,
    andrea

    Hi,
    Is this an OCCI question?
    I don't see that "to_blob" is documented anywhere. The "to_lob" function can be used to convert long raw columns, but its use is pretty specific and certainly not for general query use.
    Regards,
    Mark
    EDIT1: Well, my local documentation set does not have "to_blob" in it at all. However, it is in the 11.1 SQL Language Reference on OTN:
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/functions186.htm#sthref2358
    Despite the fact that the documentation mentions "long raw" the function appears to only work with "raw" data in my 11.1 tests.
    What's your goal here?
    Edited by: Mark Williams on Jun 8, 2009 7:15 PM

  • Help Please:  working with HTML BLOBS and workflow attachments

    simply put need to be able to:
    1. create html document using plsql and store as BLOB in a table.
    2. retrieve this BLOB and send as Document Attachment in workflow notification.
    This sounds so simple to be able to do and yet I've spent the past week trying to find easy to understand documentation on how to do this.
    The html i'm creating is too large for just the normal 32K (I believe) buffer for a regular (text) document attachment. If i limit the # of rows returned, I can use this method just fine. However, my assumption is that with the amount of data I need to return in the attachment is that the BLOB type is what i will need to be able to accomplish this.
    I would be more than happy to e-mail anyone samples of the workflow and code I am currently using to attempt this.
    Lastly, one of the main articles I've looked at is this:
    http://oracle.anilpassi.com/index2.php?option=com_content&do_pdf=1&id=22
    In my latest attempt, i picked an html file currently stored in fnd_lobs and tried to send the file as an attachment.
    wf_engine.setitemattrdocument ( itemtype => c_itemtype,
    itemkey => l_itemkey,
    aname => 'LOB_DOCUMENT',
    documentid =>'PLSQLBLOB:DANA_RLM_EXCEPTION_NOTIFY.xx_notif_attach_procedure/' || to_char(75871));
    I get the following error in Workflow when trying to open the attached document:
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    Any help would be greatly appreciated... would consider naming our next child after you. ;)

    I had done some work trying to see how Lotus Notes handles HTML content.. to my dismay, Lotus Notes does not even handle some of the basic HTML correctly.. leave alone the embedded OA Fwk content in the workflow e-mail notifications.
    This seems to be a bug in Lotus notes.. I don't have the link to the IBM site that talks abt the bug. Will post it once I have it.

  • BLOB and CLOB data in BI Publisher

    Hello,
    I have an XML file with blob and clob data in it. I am using BI desktop publisher to load the xml file and create the rtf template. I am getting the following error:
    ConfFile: C:\Program Files\Oracle\BI Publisher\BI Publisher Desktop\Template Builder for Word\config\xdoconfig.xml
    Font Dir: C:\Program Files\Oracle\BI Publisher\BI Publisher Desktop\Template Builder for Word\fonts
    Run XDO Start
    Template: C:\work\employee.rtf
    RTFProcessor setLocale: en-us
    FOProcessor setData: C:\work\employee.xml
    FOProcessor setLocale: en-us
    Do i need to install anything or am i missing any configuration to read the blob and clob? Please advise
    thanks

    Check this out, hopefully it'll help you
    http://oraclebizint.wordpress.com/2007/11/12/oracle-bi-ee-101332-working-with-clob-fields/
    Fiston

Maybe you are looking for

  • How to show or Hide Generic Column in a regular report

    Hi All, I have created report based on "SQL query (pl/sql function body returning sql query). It returns columns based on some conditions. I have total 60 generic columns like (COL1,COL2....COL60) but it returns 18 or 20 columns based on my condition

  • I don't have the airplay button

    I have a iPhone 4 ios 6.1.3 and for some reason I never get the airplay button. I do not have an apple tv, however I do have the reflector app, which is what i am trying to connect to. I have even once seen the airplay button on my phone. I am connec

  • I'm making a photo album and have decided to cut it in half and mak

    I'm making a photo album and have decided to cut it in half and make 2 books.  Has anyone been able to save the half of a photo album so they don't have to start again?

  • Proxy by URL to WebLogic 9.1

    Hello, I have just installed Sun Java System Web Server 6.1sp8 on my desktop. I have also installed WebLogic Server 9.1 on the same desktop. The issue that I have is that I cannot seem to proxy requests from Sun to WebLogic, the Sun web server keeps

  • Safari on Mini can't load a specific URL

    Safari cannot load "http://135antibes.dyndns.tv:81/" This address loads in the PC mode. Why not in the Mac mode