Use of Complex Oracle Object with JDBC

How can I use Oracle Object(or PL/Sql type) with JDBC
I have a structure of record with some attributes and table of another attribute.
My types are defined as follows !
<code>
CREATE TYPE EMPLOYEE_GRADES AS TABLE OF VARCHAR2(50)
CREATE TYPE EMPLOYEES AS OBJECT(EmpName VARCHAR2(50), EmpGrades Employee_Grades)
</code>
My custom object might have the following structure (or should it be different)
<code>
public class EmpColl implements CustomDatum, CustomDatumFactory
-- other stuff ----
/* fields */
public String empName;
public Collection empNos;
</code>
I want to pass an variable of type EMPLOYEES to an procedure.
Thanx in Advance
Chetan
[email protected]

<code>
CREATE TYPE EMPLOYEE_GRADES AS TABLE OF VARCHAR2(50)
CREATE TYPE EMPLOYEES AS OBJECT(EmpName VARCHAR2(50), EmpGrades Employee_Grades)
</code>The easiest is to use JPublisher (which comes with the SQLJ distribution).
Say:
jpub -user=username/password -sql=EMPLOYEES:Employees,EMPLOYEE_GRADES:EmployeeGrades
You will get (among others) the Java files Employees.java and EmployeeGrade.java. Go ahead, compile and use them.
Look in [Oracle Home]/sqlj/demo/jpub for a number of additional examples, and in the JPublisher User's Guide for background info.
The next (9.2) release of JPublisher will also provide some support for accessing legacy PL/SQL types from Java.

Similar Messages

  • Can't connect to external Oracle DB with JDBC connector

    Hello guys,
    I had failed to connect to connect external Oracle  via JDBC connector .
    Could you please help me to resolve the problem ?
    Backgroud:
    We need to connect the external Oracle DB with JDBC connector, because BI need to connect to the target Oracle. If the JDBC connector suceed, BI will create a UD which use the datasource
    we create in Visual admin to connect to the external Oracle DB.
    Environment:
    Our EP version is NW04S SP17 , OS is AIX .
    The target Oracle DB version is 10g(10.1.0.2.0, 64bi).
    Configuration procedure :
    1. Import Oracle driver "ojdbc14.jar" and create new driver which named "Oracle "  under
    JDBC Connector ->Run time ->Driver  in Visual Admin.
    2. Create datasource "Mydatasource" under JDBC Connector ->Run time ->Data Source,
    Name : Mydatasource
    Driver Name : Oracle
    JDBC version: 2.0(with XA support)
    JDBC compliant:
    Object Factory :oracle.jdbc.pool.OracleDataSourceFactory
    DataSource Type: ConnectionPoolDataSource
    *CPDS class name :oracle.jdbc.pool.OracleConnectionPoolDataSource
    Additional:
    Additional Properties:
    DatabaseName:LPAR8TEST
    DriverName:oracle.jdbc.OracleDriver
    Password: *****
    PortNumber:1521
    ServerName: 10.1.16.208
    URL :jdbc:oracel:[email protected]:1521:LPAR8TEST
    User:IMPL
    Connectoin Pool:
    Initial Connectons: 1                                         Expiration:  (check)
    Maximum Connections: 25                                  Connection Lifetime :600
    Maximum time wait of connection : 60                  Cleanup Thread : 200
    Default Connectoin Isolaton :Default
    SQL Engine:
    Open SQL
    3.Create Connector :
       Copy the standard connector :SDK_JDBC to SDK_JDBC_Oracle,
      Resource Adopter:
      Loader References:
      Add "libray:Oracle" .
    Managed Connection Factory:
    Configuration Property:
    DriverName:oracle.jdbc.OracleDriver
    Password: ****
    User:IMPL
    URL: jdbc:oracle:[email protected]:1521:LPAR8TEST
    All fo my configuration had been listed.
    And I had created JCO RFC : JT-BIDEV_PORTAL_BD1 , and created RFC connection with SM59 in BI.
    Please give me some suggesiton.
    Thanks.
    Louis

    When I try to start datasoure "Mydatasource" , it display error, error detail:
    java.rmi.RemoteException: com.sap.engine.services.dbpool.exceptions.BaseRemoteException: Error during start of application "sap.com/Mydatasource". [id = StartupError]
         at com.sap.engine.services.dbpool.deploy.DataSourceManagerImpl.startApplication(DataSourceManagerImpl.java:608)
    Caused by: java.rmi.RemoteException: Error occurred while starting application in whole cluster and wait.; nested exception is:
         com.sap.engine.services.deploy.exceptions.ServerDeploymentException: Clusterwide exception: server ID 3128050:com.sap.engine.services.dbpool.exceptions.BaseDeploymentException: Cannot start DataSource "CGNPC".
         at com.sap.engine.services.dbpool.deploy.ContainerImpl.startDataSource(ContainerImpl.java:1549)
    Caused by: com.sap.engine.services.dbpool.exceptions.BaseResourceException: SQLException thrown by the physical connection: java.sql.SQLException: Invalid Oracle URL specified: OracleDataSource.makeURL
         at com.sap.engine.services.dbpool.spi.CPManagedConnectionFactoryImpl.createManagedConnection(CPManagedConnectionFactoryImpl.java:198)
    Caused by: java.sql.SQLException: Invalid Oracle URL specified: OracleDataSource.makeURL
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
    Caused by: com.sap.engine.services.deploy.exceptions.ServerDeploymentException: Clusterwide exception: server ID 3128050:com.sap.engine.services.dbpool.exceptions.BaseDeploymentException: Cannot start DataSource "Mydatasource".
         at com.sap.engine.services.dbpool.deploy.ContainerImpl.startDataSource(ContainerImpl.java:1549)
    Caused by: com.sap.engine.services.dbpool.exceptions.BaseResourceException: SQLException thrown by the physical connection: java.sql.SQLException: Invalid Oracle URL specified: OracleDataSource.makeURL
         at com.sap.engine.services.dbpool.spi.CPManagedConnectionFactoryImpl.createManagedConnection(CPManagedConnectionFactoryImpl.java:198)
    Caused by: java.sql.SQLException: Invalid Oracle URL specified: OracleDataSource.makeURL
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
              u2026.
    When I try to test JDBC with URL : http://jt-pldev:50000/TestJDBC_Web/TestJDBCPage.jsp,
    First I choose connection name "SDK_JDBC_Oracle" .
    If I click "Check Connectons", it display :
    500   Internal Server Error
    SAP J2EE Engine/7.00
      Application error occurred during request processing.
      Details:
      java.lang.NoClassDefFoundError: com.sap.ip.bi.sdk.dac.connector.odbo.impl.Connection (initialization failure)
    Exception id: [001A64A86F2C006B000004C40010302A000469C74E86A096]
    If I click "Slecton Connection", it display:
    500   Internal Server Error
    SAP J2EE Engine/7.00
      Application error occurred during request processing.
      Details:
      com.sap.engine.frame.core.load.SAPNoClassDefFoundError: javax.resource.Referenceable
    Exception id: [001A64A86F2C0063000004C00010302A000469C74FA2BB59]

  • Error when create XMLType object with JDBC connection

    Hello, I try to get an XMLType object with JDBC, but it doesn't work. Can somebody help me?
    My code is :
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@"+"a02w03:1521:PROJET", "scott", "tiger");
    OraclePreparedStatement stmt = (OraclePreparedStatement) conn.prepareStatement("select xmldoc from cv_col");
    ResultSet rset = stmt.executeQuery();
    OracleResultSet orset = (OracleResultSet) rset;
    while(orset.next())
    OPAQUE o = orset.getOPAQUE(1);
    System.out.println(o.getSQLTypeName());
    XMLType poxml = XMLType.createXML(o);
    My database table:
    CREATE TABLE cv_col (
    XMLDoc xmltype
    Execution: The SQL type name "SYS.XMLTYPE" is write and then I obtain the error:
    Exception in thread main
    java.lang.NoSuchMethodError: java.lang.String oracle.jdbc.internal.OracleConnection.getProtocolType()
         at oracle.xdb.XMLType.initConn(XMLType.java:2072)
         at oracle.xdb.XMLType.<init>(XMLType.java:903)
         at oracle.xdb.XMLType.createXML(XMLType.java:493)
         at Prog.main(Prog.java:26)
    Process exited with exit code 1.
    Thank you, very much!

    What platform are you using for the database, what are you running your code on.
    Which database version are you working with.. What is your class path. What version of JDBC and OCI are in the client environment, eg what are CLASSPATH and PATH / LD_LIBRARY_PATH settings. Have you tested your code using a simple IDE like Oracle's JDeveloper or run it from directly from the command line.

  • Connecting Oracle 8i with JDBC

    Hi Friends,
    I am facing a problem while doing a connection to my DB which is ORACLE 8i with JDBC communication channels thorugh xi.
    I am getting an error "Error during database connection to the database URL 'jdbc:oracle:thin:@hostname:ORCL' using the JDBC driver 'oracle.jdbc.driver.OracleDriver': 'com.sap.aii.adapter.jdbc.sql.DriverManagerException: Cannot establish connection to URL 'jdbc:oracle:thin:@hostname:ORCL': SAPClassNotFoundException: oracle.jdbc.driver.OracleDriver"
    In one of the SAP notes:867176 its mentioned .....
    3. Which JDBC driver version is certified to connect to which database version?
                  From the Oracle side:
                  The Oracle 10g JDBC drivers are certified to work with currently-supported versions of the database.
                  JDBC 8i/9i Thin drivers are certified to work with supported (previous) versions of the database.
                  Existing and supported JDBC drivers are certified to work with Oracle Database 10g.
                  From the SAP side:
                  SAP only supports homogeneus setups. The oracle driver major version must match the database major version, and the driver version must not be smaller than the database version.
                  SAP does not support Oracle 8i drivers.
    Is it not possible to connect to my DB?  Is SAP supports the connection to 8i oracle database? any idea,,,
    Regards,
    Sunil.

    Hi,
    Following is the connection string that we are currently using for connecting to Oracle 8i.
    This setting has been working for us. give it a try.
    connection string : jdbc:oracle:oci8:userid/password@server
    Note that this connection string is only if you use the Oracle OCI driver. The OCI driver requires a shared library or DLL on the server.
    The thin driver for Oracle is more commonly used as it doesn't require any additional libraries. The connection string is as already listed above:
    jdbc.oracle.thin:@server:port:SID
    There is no need to put the user and password into the connection string in the adapter config, putting it into the user and password fields works just fine.
    Regards,
    Suryanarayana

  • Using JCheckBox, JButton and JTextArea with JDBC

    Hello shlumph and SoulTech2012.
    thanks for the reply. I�m wondering do any of you have links to web pages that include tutorials and source code on using JCheckBox, JButton and JTextArea with JDBC. would any of you who have experience with using JCheckBox, JButton, JTextArea and JDBC together be able to give me a few tips on how to select certain data from a table using JCheckBox, JButton and display the data in a JTextArea? examples of such data could be CD/DVD/Game data - i want users of my video library system to be able to view CD/DVD/Game information by name, age category, type and year. Users should be able to click on a check box (e.g. view by name, age category, type or year) and press a button. What would happen then is that data from the Product table would appear in the text area (which could be placed beneath the check box + button inside a frame and/or panel).
    Thank you very much for your help.

    Quit triple posting and cross posting your questions all over the forum. You already have a posting in this forum on this topic and another posting in the Swing forum and another posting in the Programming forum.

  • Oracle lite with JDBC crashes

    I am connecting to an Oracle lite database on NT Server 4.0 with
    JDBC and trying to run an simple insert statement. If I try to
    run the same statement again (which should throw an exception
    since the pk already exists) I get an application error - not an
    exception as expected - I get the same thing when executing a
    "delete from.." stmt on an empty table. These same stmts work
    fine in Oracle8i.
    Also, if I use access with ODBC to view the tables access will
    often freeze up on me.
    Any Help would be appreciated.
    Dylan
    null

    You probably mean if you can call a Java Stored Procedure from ADOCE application. PL/SQL packages are not supported in Oracle Lite database. The answer is no. For more information see Developers' Guide for WindowsCE, Chapter 4

  • Using a polymorphic view object with binding

    Hi,
    I'm hoping there's something simple I'm missing when trying to setup up the bindings for a ADF/struts page using a polymorphic view object.
    I'm using Entity and VO polymorphism to create a Question which has different types - boolean, multi-choice, likert, etc. I have the various question types created as sub type entity and view objects and added to the app module - when added to the app module the question types are subtypes of QuestionView so they don't actually appear in the Data Controls palette. This setup is like that used in Steve Muench's examples (blog at http://radio.weblogs.com/0118231/stories/2003/02/06/constructingTheDesiredEntityInAPolymorphicViewObject.html and the related undocumented one)
    My question is, how do I get to the data and have jdev create the necessary bindings for the extra attributes the subtype questions have? Since they don't appear as available data controls I can't create a binding iterator or anything for them - short of adding them as spearate view objects (which destroys the whole point of using polymorphism in this case) is there a way to do this?
    Really, the only reason I want to use the polymorphism is so I can have different types of entity validation depending on the type. Should I just simplify this to be one entity object with one VO and put all the validation into "if else's" based on a discriminator?
    Assistance appreciated...
    - Nathaniel

    How else are you planning to associate a JUTableBinding to the 'common' iterator containing all four types of rows and then selectively display them? Perhaps you'd need a custom model over the JUTabelModel that'd filter the rows out.
    I'm not sure if all that trouble is worth it given that your datasets (as far as mentioned in this post) are not large. If these tables/data has to be refreshed/executed a number of times, then you may see the overhead of four queries otherwise it should be fine as database is always faster in filtering rows than doing that in memory.

  • How can I use methods of an object with private instantiation in my ABAP?

    Hello all,
    What is the work-around on using methods of an object marked as private instantiation? I tried to use concepts of <b>INHERITANCE</b> or <b>FRIENDS</b> of an object (<u>BCONTACT </u> in my case - a SAP standard object) but it did not work, or at least, I do not know how to properly code the statements in my ABAP program.
    Any code samples, other ideas?
    Your help is greatly appreciated.

    I am closing this question as there has been no answer.
    Message was edited by:
            Goharjou ardavan

  • Local oracle access with jdbc thin

    hello there
    it need help despratly,
    im developing an applet to talk to remote oracle dbs using jdbc
    thin
    but i also want an applet to be able to talk to a local oracle db
    on the same hardisk.
    for a remote connection the follwing stringis used at my
    university
    static final String connect_string =
    "jdbc:oracle:thin:scott/[email protected]:1521:DSC1";
    but what do i subsitute for thr host as i want to access the db
    on my hard disk?
    i need as much help ASP, as im well behind my schedule for this
    project.?
    also i take it that to allow this and access to remote servers
    other than the web server, the applet needs to be signed, is this
    possible with jdk1.1.x compatble browsers?
    yours
    richard sergio marchesi
    email - [email protected]
    or
    email - [email protected]
    null

    The thin driver reqiures a TCP listener to be running. If you are
    using Personal Oracle for the 'local' RDBMS then it doesn't have
    a listener (with the default installation). Start the listener
    and you should be able to connect. You will also want a local
    webserver of some sort to serve the applet to you as well, but
    anything (even TinyWeb) will do for that.
    null

  • Trouble to connect to Oracle Lite with JDBC

    Hi.
    I have installed Oracle Lite 9i on my PC (Win 2000 Pro). Then I connected an HP Jornada 525 (WinCE 3.0) and with
    ActiveSync I installed the Oracle Mobile Client. Using MSql, I created some tables and did some data inserts - Oracle
    is working fine on the Pocket PC. The next step was to create an Java application that will run on the Jornada to
    connect to this database and edit its data. Here is the initial source code:
    import java.sql.*;
    public class JDBCEX {
    public void JDBCEX () {
    public static void main(String args[]) {
    Connection conn = null;
    Statement stmt = null;
    ResultSet retset = null;
    try {
    Class.forName("oracle.lite.poljdbc.POLJDBCDriver");
    conn = DriverManager.getConnection("jdbc:Polite:Polite","system", "manager");
    catch (Exception e) {
    System.out.println(e);
    System.exit(0);
    This works fine on my PC, but in the Pocket PC it gave me: java.sql.SQLException: Internal Error. This after I expanded
    the jar files, 'cause before it tells me that ther is no oljdbc40 on the shared library path. I adjusted the classpath on the
    registry, but i does not have any impact ... There is no file with name oljdbc40, only JARs olite40 and olitejdbc40. I installed
    olitejdbcpj40.jar, and setting this library leads to the same error above.
    What could be wrong? Do you have any tutorial or can you list all steps necessary to bring this working?
    Thanks

    If you're attempting to use the ODBC API directly, have you downloaded the ODBC SDK from Microsoft? That will include some sample code, which is a great starting point. So far as I'm aware, you shouldn't need to configure anything in Borland C++ that you don't have to configure in any other C++ compiler to use ODBC.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Tutorial on using a non-database object with ADF?

    I'm just starting with ADF and could use some advice. I'm making my way through the first ADF 11g tutorial ("Developing Rich Web Applications with Oracle ADF") and just want to make sure I'm headed in the right direction.
    While the tutorial is an excellent step-by-step explanation of how to bind database information to forms, I'm trying to figure out how to create an ADF web page that gets its fields created from an object (e.g. Java POJO). Is there a tutorial on this (Java object vs database object form creation)?
    Thanks

    Hi,
    See if the below link helps:
    http://technology.amis.nl/blog/3802/adf-11g-model-driven-display-properties-in-pojo-based-data-controls
    Sireesha

  • Connecting to Oracle DB with JDBC ...

    I receive this err when i run my codes
    java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=150999297)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
    Interactive Session Ended
    Below is my codes.
    // header - edit "Data/yourJavaHeader" to customize
    // contents - edit "EventHandlers/Java file/onCreate" to customize
    import java.sql.*;
    class MakingTheConnection
         public static void main(String[] args)
              Connection connection = null;
    Statement stmt = null;
              try
                        System.out.println("Hello 1");
    Class.forName("oracle.jdbc.driver.OracleDriver");
                                                 System.out.println("Hello 2");
    catch(java.lang.ClassNotFoundException e)
    System.err.print("ClassNotFoundException: ");
    System.err.println(e.getMessage());
    try
                        System.out.println("Hello 2");
    //connection = DriverManager.getConnection("jdbc:oracle:thin:@172.20.134.95:1521:SNP", "system", "manager");
                        connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:SNP", "system", "manager");
    stmt = connection.createStatement();
              catch(java.sql.SQLException ex)
    System.err.print("SQLException: ");
    System.err.println(ex.getMessage());
              try
                        System.out.println("Hello 3");
    if (stmt!=null)
    {stmt.close();}
    if (connection!=null)
    {connection.close();}
    catch(Exception e)
    e.printStackTrace();
              //load the driver
              try
                   Class.forName("oracle.jdbc.driver.OracleDriver");
                   //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   String sourceURL = "jdbc:oracle:thin:@172.20.134.95:1521:SNP";
                   //String sourceURL = "jdbc:oracle:thin:@172.20.134.95:389:SNP";
                   String user = "system";
                   String password = "manager";
                   Connection databaseConnection = DriverManager.getConnection(sourceURL, user, password);
                   System.out.println("connected");
                   databaseConnection.close();
              catch (ClassNotFoundException cnfe)
              System.out.println(cnfe);
              catch(SQLException sqle)
              System.err.println(sqle);
    Do not uncomment the codes i put as comments coz they are not used :)
    I really need help here..thankz.

    Hi:
    That error code is Service Name related error.
    Oracle error docs has the following
    TNS-12505 TNS:listener could not resolve SID given in connect descriptor
    Cause: The SID in CONNECT_DATA was not found in the listener's tables.
    Action: Check to make sure that the SID specified is correct. The SIDs that are currently registered with the listener can be obtained by typing "LSNRCTL SERVICES listener_name". These SIDs correspond to SID_NAMEs in TNSNAMES.ORA, or DB_NAMES in the INIT.ORA file.

  • Getting varchar objects as "???" while using struct for oracle object type

    Hi all.
    I have a problem whith VARCHAR values which is returned from an oracle function. The function returns an oracle type and I get it using STRUCT. I can get all non VARCHAR values of the TYPE like NUMBER and TIME without any problem. But when I get VARCHAR values, they all come as if equal to"???". I called the database function in TOAD and everything works perfect. It seems that somewhere in between we loose the information. Has anyone encountered such a strange problem?
    Part of the code look like:
    CallableStatement callState = null;
              ResultSet rs = null;
              UOAReturnType result= new UOAReturnType();
              try
                   callState = getConnection().prepareCall("{?=call Call.UACBS.GETREDL(?)}");
                   callState.registerOutParameter(1, OracleTypes.STRUCT,"CALL.TYPE_REDL_RO");
                   callState.setString(2,msisdn);
                   callState.execute();
                   Struct RedlRoStrct = (Struct)callState.getObject(1);
                   Object[] redlRo = RedlRoStrct.getAttributes();
                   Struct redlStruct = (Struct)redlRo[0];
                   Object[] redl =null;
                   if(redlStruct!=null){
                        redl = redlStruct.getAttributes();
                        result.setMsisdn(redl[0].toString());
                        try {
                             result.setTime(UtilDate.getDate(redl[1].toString(),dateFormat,custLocale));
                        } catch (NullPointerException e2) {
                             result.setTime(null);
                             e2.printStackTrace();
                        result.setReason(Integer.parseInt(redl[2].toString()));
                        result.setSource(redl[3].toString());
                   Struct opReturnStruct = (Struct)redlRo[1];
                   Object[] opReturn = opReturnStruct.getAttributes();
                   result.setResultCode(Integer.parseInt(opReturn[0].toString()));
                   result.setResultDescription(opReturn[1].toString());Any idea will be appreciated.
    Thanks.......

    Hi,
    I don't think it is a java problem.You can see time and number types because the characters are digits. My guess is that it has something to do with some settings on the client. Try to have the NLS_LANG environment variable appropriately set. Also try invoking your test script from sqlplus to see if the results actually work.
    Kiros

  • Connecting to an oracle db with jdbc

    I downloaded the jdbc drivers and unzipped them to "C:\SDK\Classes", therefore they're "C:\SDK\Classes\oracle\jdbc\..."
    My classpath is set to "C:\SDK\Classes\"
    public void connect()
            String serverName = "********";
            String portNumber = "1521";
            String sid = "oracle9";
            String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
            String username = "*****";
            String password = "*****";
           Connection connection = null;
         try
                String driverName = "oracle.jdbc.driver.OracleDriver";
                Class.forName(driverName);
         // Create a connection to the database
         connection = DriverManager.getConnection(url, username, password);
         catch (ClassNotFoundException e)
            System.out.println("Could not find the database driver");
             catch (SQLException e)
                System.out.println("Could not connect to the database");
    }I get the error "Could not find the database driver" when i run this.
    Can anyone suggest anything?
    Thanks!

    Check your classpath and webserver library directory
    it must be classes12.jar file in the lib directory that using the webserver
    or classpath
    .;c:\jdk1.3.1\extlib\classes12.jar;
    and check your jdbc driver version

  • Create Oracle Object with array inside

    Hi
    I want create a db type with an attribute of dbms_sql.varchar2_table  type
    Example:
    create or replace type t_obj_gest_csv_h
       as object
    column_value_list dbms_sql.varchar2_table,
    It's possible?
    Stefano

    Not with dbms_sql.varchar2_table. You can't reference PL/SQL types when creating SQL type. You can create SQL nested table type and use it in object type:
    SQL> create or replace
      2    type StringList
      3      as table of varchar2(4000)
      4  /
    Type created.
    SQL> create or replace
      2    type t_obj_gest_csv_h
      3      as object(
      4                id number,
      5                s  StringList
      6               )
      7  /
    Type created.
    SQL>
    SY.

Maybe you are looking for