JDBC CLOB WRITER

I do not know how to setup a Clob Writer - what is wrong with the following approach? (I'm getting a null pointeer exception?)
- Tor
          Clob xmlClob = null;
          try {
               db.open();
               Connection c = db.getDbConnection();
               ResultSet r = db
                         .sqlSELECT("select slm_xml_doc from slm for update ");
               r.next();
               ResultSetMetaData md = r.getMetaData();
               System.out.println(" Col#: " + (1) + " Attribute: "
                         + md.getColumnName(1) + " DT: "
                         + md.getColumnTypeName(1));
               Clob xmlclob = r.getClob(1);
          } catch (Exception s) {
               System.out.println("DB or Clob Error: " + s.getMessage());
          try {
               Writer writer = xmlClob.setCharacterStream(0);
          } catch (Exception s) {
               System.out.println("Writer Error: " + s.getMessage());
Output from unit test:
INFO -Database connection is: oracle.jdbc.driver.T4CConnection@1172e08 (com.tor.sdmds.utilities.Database)
Col#: 1 Attribute: SLM_XML_DOC DT: CLOB
Writer Error: null

FIXED - typo! Tor

Similar Messages

  • Jdbc Clob

    When Iam trying to save data into clob type of oracle using Pooled Connection it is giving the following exception
    java.lang.ClassCastException: weblogic.jdbc.rmi.SerialResultSet at....
    But it is saving fine with Normal connection. Iam using Weblogic 6.1(sp2) and Oracle 9.9.1.1.1 with thin drivers.
    The code is like this
    select clob_col from tablename for update;
    oracle.sql.CLOB objClob=((OracleResultSet)objResultSet).getCLOB(strColumnName);
                                  Writer objClobWrite=objClob.getCharacterOutputStream();
    Please help me on this issue.
    Regards,
    Phani

    Hi Phani,
    Phaneendra <[email protected]> wrote:
    When Iam trying to save data into clob type of oracle using Pooled Connection
    it is giving the following exception
    java.lang.ClassCastException: weblogic.jdbc.rmi.SerialResultSet at....
    But it is saving fine with Normal connection. Iam using Weblogic 6.1(sp2)
    and Oracle 9.9.1.1.1 with thin drivers.
    The code is like this
    select clob_col from tablename for update;
    oracle.sql.CLOB objClob=((OracleResultSet)objResultSet).getCLOB(strColumnName);
                                  Writer objClobWrite=objClob.getCharacterOutputStream();
    Please help me on this issue.
    Regards,
    PhaniWhen u r using clob or blob from weblogic you have use classes from package weblogic.jdbc.rmi
    for uploading a clob do it like
    ps = conn.prepareStatement("select data from urtable where ID=? for update");
    ps.setString(1, ID);
    ResultSet rsclob = ps.executeQuery();
    if(rsclob.next()) {
    weblogic.jdbc.rmi.SerialClob dclob = (weblogic.jdbc.rmi.SerialClob)rsclob.getClob(1);
    try {
    Writer datawrt = (Writer)dclob.getCharacterOutputStream();
    datawrt.write(msg);
    datawrt.flush();
    datawrt.close();
    catch(IOException iex) {
    throw new Exception("Error while writing clob object");
    rsclob.close();
    u can do the similiar thing for Blob as well.
    Regards
    Balendran

  • Using JDBC to write a DAT file with delimiters to a database

    Hi Everybody
    I am new to JDBC and i am trying out some small applications: I downloaded this small program and tried to compile it and and I got the following errors: ( I have MySql installed). I have to set the classpath for the driver. But I am not sure why I am gettting the NullPointerException though)
    I will be very gratefull to your help. Thanks a lot..
    Loading JDBC Driver -> oracle.jdbc.driver.OracleDriver
    java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
         at java.net.URLClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClassInternal(Unknown Source)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Unknown Source)
         at us.ilango.WriteFileToTable.<init>(WriteFileToTable.java:69)
         at us.ilango.WriteFileToTable.main(WriteFileToTable.java:367)
    java.lang.NullPointerException
         at us.ilango.WriteFileToTable.createTable(WriteFileToTable.java:97)
         at us.ilango.WriteFileToTable.main(WriteFileToTable.java:368)
    Exception in thread "main"
    the Program is as follows:
    package us.ilango;
    import java.sql.DriverManager;
    import java.sql.Connection;
    import java.sql.Statement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.StringTokenizer;
    import java.io.FileReader;
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.util.Date;
    import java.text.SimpleDateFormat;
    import java.text.NumberFormat;
    import java.text.ParseException;
    * The following class provides an example of how to read a simple text file
    * of records and then insert them into a table in a database. A text file
    * named Employee.txt will contain employee records to be inserted into the
    * following table:
    *      SQL> desc emp
    *      Name              Null?    Type
    *      EMP_ID              NOT NULL NUMBER
    *      DEPT_ID                      NUMBER
    *      NAME                NOT NULL VARCHAR2(30)
    *      DATE_OF_BIRTH       NOT NULL DATE
    *      DATE_OF_HIRE        NOT NULL DATE
    *      MONTHLY_SALARY      NOT NULL NUMBER(15,2)
    *      POSITION            NOT NULL VARCHAR2(100)
    *      EXTENSION                    NUMBER
    *      OFFICE_LOCATION              VARCHAR2(100)
    * NOTE: This example will provide and call a method that creates the EMP
    *       table. The name of the method is called createTable() and is called
    *       from the main() method.
    public class WriteFileToTable {
        final static String driverClass    = "oracle.jdbc.driver.OracleDriver";
        final static String connectionURL  = "jdbc:oracle:thin:@localhost:1521:CUSTDB";
        final static String userID         = "scott";
        final static String userPassword   = "tiger";
        final static String inputFileName  = "Employee.txt";
        final static String TABLE_NAME     = "EMP";
        final static String DELIM          = ",";
        Connection   con                   = null;
         * Construct a WriteFileToTable object. This constructor will create an
         * Oracle database connection.
        public WriteFileToTable() {
            try {
                System.out.print("  Loading JDBC Driver  -> " + driverClass + "\n");
                Class.forName(driverClass).newInstance();
                System.out.print("  Connecting to        -> " + connectionURL + "\n");
                this.con = DriverManager.getConnection(connectionURL, userID, userPassword);
                System.out.print("  Connected as         -> " + userID + "\n");
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (SQLException e) {
                e.printStackTrace();
         * Method used to create the initial EMP table. Before attempting to create
         * the table, this method will first try to drop the table.
        public void createTable() {
            Statement stmt = null;
            try {
                stmt = con.createStatement();
                System.out.print("  Dropping Table: " + TABLE_NAME + "\n");
                stmt.executeUpdate("DROP TABLE " + TABLE_NAME);
                System.out.print("    - Dropped Table...\n");
                System.out.print("  Closing Statement...\n");
                stmt.close();
            } catch (SQLException e) {
                System.out.print("    - Table " + TABLE_NAME + " did not exist.\n");
            try {
                stmt = con.createStatement();
                System.out.print("  Creating Table: " + TABLE_NAME + "\n");
                stmt.executeUpdate("CREATE TABLE emp (" +
                                 "    emp_id           NUMBER NOT NULL " +
                                 "  , dept_id          NUMBER " +
                                 "  , name             VARCHAR2(30)  NOT NULL " +
                                 "  , date_of_birth    DATE          NOT NULL " +
                                 "  , date_of_hire     DATE          NOT NULL " +
                                 "  , monthly_salary   NUMBER(15,2)  NOT NULL " +
                                 "  , position         VARCHAR2(100) NOT NULL " +
                                 "  , extension        NUMBER " +
                                 "  , office_location  VARCHAR2(100))");
                System.out.print("    - Created Table...\n");
                System.out.print("  Closing Statement...\n");
                stmt.close();
            } catch (SQLException e) {
                e.printStackTrace();
         * Method used to read records from Employee.txt file then write the records
         * to an Oracle table within the database named "EMP".
        public void performLoadWrite() {
            Statement stmt          = null;
            int       insertResults = 0;
            StringTokenizer st = null;
            String  emp_id;
            String  dept_id;
            String  name;
            String  date_of_birth;
            String  date_of_hire;
            String  monthly_salary;
            String  position;
            String  extension;
            String  office_location;
            try {
                System.out.print("  Creating Statement...\n");
                stmt = con.createStatement ();
                System.out.print("  Create FileReader Object for file: " + inputFileName + "...\n");
                FileReader inputFileReader = new FileReader(inputFileName);
                System.out.print("  Create BufferedReader Object for FileReader Object...\n");
                BufferedReader inputStream   = new BufferedReader(inputFileReader);
                String inLine = null;
                while ((inLine = inputStream.readLine()) != null) {
                    st = new StringTokenizer(inLine, DELIM);
                    emp_id   = st.nextToken();
                    dept_id  = st.nextToken();
                    name     = st.nextToken();
                    date_of_birth = st.nextToken();
                    date_of_hire = st.nextToken();
                    monthly_salary = st.nextToken();
                    position = st.nextToken();
                    extension = st.nextToken();
                    office_location = st.nextToken();
                    System.out.print("  Inserting value for [" + name + "]\n");
                    insertResults = stmt.executeUpdate(
                            "INSERT INTO " + TABLE_NAME + " VALUES (" +
                                      emp_id +
                            "  ,  " + dept_id +
                            "  , '" + name + "'" +
                            "  , '" + date_of_birth + "'" +
                            "  , '" + date_of_hire + "'" +
                            "  ,  " + monthly_salary +
                            "  , '" + position + "'" +
                            "  ,  " + extension +
                            "  , '" + office_location + "')");
                    System.out.print("    " + insertResults + " row created.\n");
                System.out.print("  Commiting Transaction...\n");
                con.commit();
                System.out.print("  Closing inputString...\n");
                inputStream.close();
                System.out.print("  Closing Statement...\n");
                stmt.close();
            } catch (SQLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
         * Method used to query records from the database table EMP. This method
         * can be used to verify all records have been correctly loaded from the
         * example text file "Employee.txt".
        public void queryRecords() {
            Statement stmt           = null;
            ResultSet rset           = null;
            int       deleteResults  = 0;
            int       rowNumber      = 0;
            int     emp_id;
            int     dept_id;
            String  name;
            String  date_of_birth;
            Date    date_of_birth_p;
            String  date_of_hire;
            Date    date_of_hire_p;
            float   monthly_salary;
            String  position;
            int     extension;
            String  office_location;
            try {
                SimpleDateFormat formatter      = new SimpleDateFormat("yyyy-MM-dd");
                NumberFormat     defaultFormat  =     NumberFormat.getCurrencyInstance();
                System.out.print("  Creating Statement...\n");
                stmt = con.createStatement ();
                System.out.print("  Opening query for table: " + TABLE_NAME + "...\n");
                rset = stmt.executeQuery ("SELECT * FROM emp ORDER BY emp_id");
                while (rset.next ()) {
                    rowNumber = rset.getRow();
                    emp_id = rset.getInt(1);
                    if ( rset.wasNull() )   {emp_id = -1;}
                    dept_id = rset.getInt(2);
                    if ( rset.wasNull() )   {dept_id = -1;}
                    name = rset.getString(3);
                    if ( rset.wasNull() )   {name = "<null>";}
                    date_of_birth = rset.getString(4);
                    if ( rset.wasNull() ) {date_of_birth = "1900-01-01";}
                    try {
                        date_of_birth_p = formatter.parse(date_of_birth);
                    } catch (ParseException e) {
                        date_of_birth_p = new Date(0);
                    date_of_hire = rset.getString(5);
                    if ( rset.wasNull() ) {date_of_hire = "1900-01-01";}
                    try {
                        date_of_hire_p = formatter.parse(date_of_hire);
                    } catch (ParseException e) {
                        date_of_hire_p = new Date(0);
                    monthly_salary = rset.getFloat(6);
                    if ( rset.wasNull() ) {monthly_salary = 0;}
                    position = rset.getString(7);
                    if ( rset.wasNull() ) {position = "<null>";}
                    extension = rset.getInt(8);
                    if ( rset.wasNull() )   {extension = -1;}
                    office_location = rset.getString(9);
                    if ( rset.wasNull() ) {office_location = "<null>";}
                    System.out.print(
                        "\n" +
                        "  RESULTS -> [R" + rowNumber + "] " + "\n" +
                        "      Employee ID     : " + emp_id + "\n" +
                        "      Department ID   : " + dept_id + "\n" +
                        "      Employee Name   : " + name + "\n" +
                        "      D.O.B.          : " + date_of_birth_p + "\n" +
                        "      Date of Hire    : " + date_of_hire_p + "\n" +
                        "      Monthly Salary  : " + defaultFormat.format(monthly_salary) + "\n" +
                        "      Position        : " + position + "\n" +
                        "      Extension       : x" + extension + "\n" +
                        "      Office Location : " + office_location +
                        "\n");
                System.out.print("  Closing ResultSet...\n");
                rset.close();
                System.out.print("  Closing Statement...\n");
                stmt.close();
            } catch (SQLException e) {
                e.printStackTrace();
         * Close down Oracle connection.
        public void closeConnection() {
            try {
                System.out.print("  Closing Connection...\n");
                con.close();
            } catch (SQLException e) {
                e.printStackTrace();
         * Sole entry point to the class and application.
         * @param args Array of String arguments.
         * @exception java.lang.InterruptedException
         *            Thrown from the Thread class.
        public static void main(String[] args)
                throws java.lang.InterruptedException {
            WriteFileToTable runExample = new WriteFileToTable();
            runExample.createTable();
            runExample.performLoadWrite();
            runExample.queryRecords();
            runExample.closeConnection();
        }

    Hi
    Thanks a lot. I ran the program with the MySql driver as follows:
    The errors are as follows: I will ttry to place the Driver in the Classpath. As far as I know the driver has been specified correctly this time.
    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
         at java.net.URLClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClassInternal(Unknown Source)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Unknown Source)
         at us.ilango.WriteAntennas.<init>(WriteAntennas.java:41)
         at us.ilango.WriteAntennas.main(WriteAntennas.java:377)
    java.lang.NullPointerException
         at us.ilango.WriteAntennas.createTable(WriteAntennas.java:70)
         at us.ilango.WriteAntennas.main(WriteAntennas.java:378)
    Exception in thread "main" Loading JDBC Driver -> com.mysql.jdbc.Driver
    The program is as follows:
    package us.ilango;
    * @author ilango
    import java.sql.DriverManager;
    import java.sql.Connection;
    import java.sql.Statement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.StringTokenizer;
    import java.io.FileReader;
    import java.io.BufferedReader;
    import java.io.IOException;
    public class WriteAntennas {
        final static String driverClass    = "com.mysql.jdbc.Driver";
        final static String connectionURL  = "jdbc:mysql://localhost/test2";
        final static String userID         = "brian";
        final static String userPassword   = " ";
        final static String inputFileName  = "CO.DAT";
        final static String TABLE_NAME     = "CELL";
        final static String DELIM          = "|";
        Connection   con                   = null;
        public WriteAntennas() {
            try {
                System.out.print("  Loading JDBC Driver  -> " + driverClass + "\n");
                Class.forName(driverClass).newInstance();
                System.out.print("  Connecting to        -> " + connectionURL + "\n");
                this.con = DriverManager.getConnection(connectionURL, userID, userPassword);
                System.out.print("  Connected as         -> " + userID + "\n");
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (SQLException e) {
                e.printStackTrace();
         * Method used to create the initial EMP table. Before attempting to create
         * the table, this method will first try to drop the table.
        public void createTable() {
            Statement stmt=null;
            try {
                stmt = con.createStatement();
                System.out.print("  Dropping Table: " + TABLE_NAME + "\n");
                stmt.executeUpdate("DROP TABLE " + TABLE_NAME);
                System.out.print("    - Dropped Table...\n");
                System.out.print("  Closing Statement...\n");
                stmt.close();
            } catch (SQLException e) {
                System.out.print("    - Table " + TABLE_NAME + " did not exist.\n");
            try {
                stmt = con.createStatement();
                System.out.print("  Creating Table: " + TABLE_NAME + "\n");
                stmt.executeUpdate("create table TOWER_PUBACC_CO (" +
         "record_type               char(2)              null" +
         ", content_indicator         char(3)              null" +
         ", file_number               char(8)              null" +
         ", registration_number       char(7)              null" +
         ", unique_system_identifier  long(9,0)         not null" +
         ", coordinate_type           char(1)              not null" +
         ",latitude_degrees          int                  null" +
         ",latitude_minutes          int                  null" +
         ",latitude_seconds          int(4,1)         null" +
         ",latitude_direction        char(1)              null" +
         ",latitude_total_seconds    int(8,1)         null" +
         ",longitude_degrees         int                  null" +
         ",longitude_minutes         int                  null" +
         ",longitude_seconds         int(4,1)         null" +
         ",longitude_direction       char(1)              null" +
         ",longitude_total_seconds   int(8,1)         null)" );
                System.out.print("   created Table...\n");
                System.out.print("  closing Statement...\n");
                stmt.close();
            } catch (SQLException e) {
                e.printStackTrace();
        public void performLoadWrite() {
            Statement stmt          = null;
            int       insertResults = 0;
            StringTokenizer st = null;
            String record_type ;
            String  content_indicator;
            String file_number ;
            String registration_number;
             String unique_system_identifier ;
            String coordinate_type;
            String latitude_degrees;
            String  latitude_minutes;
            String latitude_seconds;
            String latitude_direction;
            String latitude_total_seconds;
            String longitude_degrees;
           String longitude_minutes;
           String longitude_seconds;
           String longitude_direction;
           String longitude_total_seconds;
            try {
                System.out.print("  Creating Statement...\n");
                stmt = con.createStatement ();
                System.out.print("  Create FileReader Object for file: " + inputFileName + "...\n");
                FileReader inputFileReader = new FileReader(inputFileName);
                System.out.print("  Create BufferedReader Object for FileReader Object...\n");
                BufferedReader inputStream   = new BufferedReader(inputFileReader);
                String inLine = null;
                while ((inLine = inputStream.readLine()) != null) {
                    st = new StringTokenizer(inLine, DELIM);
                    record_type   = st.nextToken();
                   content_indicator = st.nextToken();
                    file_number    = st.nextToken();
                    registration_number = st.nextToken();
                    unique_system_identifier = st.nextToken();
                   coordinate_type =st.nextToken();
                   latitude_degrees  = st.nextToken();
                   latitude_minutes = st.nextToken();
                    latitude_seconds=st.nextToken();
                   latitude_direction = st.nextToken();
                    latitude_total_seconds =st.nextToken();
                    longitude_degrees= st.nextToken();
                    longitude_minutes = st.nextToken();
                    longitude_seconds = st.nextToken();
                    longitude_direction=st.nextToken();
                    longitude_total_seconds =st.nextToken();
                    System.out.print("  Inserting value for [" + unique_system_identifier + "]\n");
                    insertResults = stmt.executeUpdate(
                            "INSERT INTO " + TABLE_NAME + " VALUES (" +
                                      record_type +
                            "  ,  " + content_indicator +
                            "  , '" + file_number + "'" +
                            "  , '" + registration_number + "'" +
                            "  , '" + unique_system_identifier + "'" +
                            "  ,  " + coordinate_type + "'" +
                            "  , '" + latitude_degrees + "'" +
                            "  ,  " + latitude_minutes + "'" +
                            "  , '" + latitude_seconds + "'" +
                            "  , '" + latitude_direction + "'" +
                            "  , '" + latitude_total_seconds + "'" +
                           "  , '" + longitude_minutes + "'" +
                           "  , '" + longitude_seconds + "'" +
                          "  , '" + longitude_direction + "'" +
                           "  , '" + longitude_total_seconds + "')");
                    System.out.print("    " + insertResults + " row created.\n");
                System.out.print("  Commiting Transaction...\n");
                con.commit();
                System.out.print("  Closing inputString...\n");
                inputStream.close();
                System.out.print("  Closing Statement...\n");
                stmt.close();
            } catch (SQLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
        public void queryRecords() {
            Statement stmt           = null;
            ResultSet rset           = null;
            int       deleteResults  = 0;
            int       rowNumber      = 0;
            String   record_type;
            String   content_indicator;
            String  file_number;
            String registration_number ;
            long  unique_system_identifier;
            String coordinate_type ;
            int   latitude_degrees ;
            int latitude_minutes ;
            int latitude_seconds;
            String latitude_direction;
            int  latitude_total_seconds;
            int     longitude_degrees;
             int longitude_minutes;
               int     longitude_seconds;
                 String longitude_direction;
           int  longitude_total_seconds;
            try {
                System.out.print("  Creating Statement...\n");
                stmt = con.createStatement ();
                System.out.print("  Opening query for table: " + TABLE_NAME + "...\n");
                rset = stmt.executeQuery ("SELECT * FROM cell ORDER BY unique_system_identifier");
                while (rset.next ()) {
                    rowNumber = rset.getRow();
                    unique_system_identifier = rset.getInt (1);
                    if ( rset.wasNull() )   {unique_system_identifier = -1;}
                    record_type = rset.getString (2);
                    if ( rset.wasNull() )   {record_type = "<null>";}
                    content_indicator = rset.getString(3);
                    if ( rset.wasNull() )   {content_indicator = "<null>";}
                    file_number = rset.getString(4);
                    if ( rset.wasNull() ) {file_number = "<null>";}
                    registration_number = rset.getString(5);
                    if ( rset.wasNull() ) {registration_number = "<null>";}
                    coordinate_type = rset.getString(6);
                    if ( rset.wasNull() )   {coordinate_type = "<null>";}
                    latitude_degrees = rset.getInt(7);
                    if ( rset.wasNull() ) {latitude_degrees = 1;}
    latitude_minutes = rset.getInt(8);
                    if ( rset.wasNull() ) {latitude_minutes = 1;}
    latitude_seconds = rset.getInt(9);
                    if ( rset.wasNull() ) {latitude_seconds = 1;}
    latitude_direction = rset.getString(10);
                    if ( rset.wasNull() ) {latitude_direction = "<null>";}
    latitude_total_seconds = rset.getInt(11);
                    if ( rset.wasNull() ) {latitude_total_seconds = 1;}
    longitude_degrees = rset.getInt(12);
                    if ( rset.wasNull() ) {longitude_degrees = 1;}
    longitude_minutes = rset.getInt(13);
                    if ( rset.wasNull() ) {longitude_minutes = 1;}
    longitude_seconds = rset.getInt(14);
                    if ( rset.wasNull() ) {longitude_seconds = 1;}
    longitude_direction = rset.getString(15);
                    if ( rset.wasNull() ) {longitude_direction = "<null>";}
    longitude_total_seconds = rset.getInt(16);
                    if ( rset.wasNull() ) {longitude_total_seconds = 1;}
                    System.out.print(
                        "\n" +
                        "  RESULTS -> [R" + rowNumber + "] " + "\n" +
                        "  Unique_System_Identifier         : " + unique_system_identifier  + "\n" +
                        "  Record_type     : " + record_type   + "\n" +
                        "  Content_Indicator      : " + content_indicator   + "\n" +
                        "  Registration_Number              : " + registration_number   + "\n" +
                        "  File_Number        : " +  file_number  + "\n" +
                        "  Coordinate_Type     : " + coordinate_type  + "\n" +
                        "  Latitude_Degrees          : " + latitude_degrees + "\n" +
                        "  Latitude_Minutes          : " + latitude_minutes + "\n" +
                        "  Latitude_Seconds           : " + latitude_seconds + "\n" +
                        " Latitude_Direction            : " + latitude_direction + "\n" +
                        "  Latitude_Total_Seconds           : " + latitude_total_seconds + "\n" +
                        "  Longitude_Degrees           : " + longitude_degrees + "\n" +
                        "  longitude_minutes           : " + longitude_minutes + "\n" +
                        "  Longitude_Seconds           : " + longitude_seconds + "\n" +
                       "     longitude_direction        : " + longitude_direction + "\n" +
                       "  Longitude_Total_Seconds           : " + longitude_total_seconds +
                       "\n");
                System.out.print("  Closing ResultSet...\n");
                rset.close();
                System.out.print("  Closing Statement...\n");
                stmt.close();
            } catch (SQLException e) {
                e.printStackTrace();
        public void closeConnection() {
            try {
                System.out.print("  Closing Connection...\n");
                con.close();
            } catch (SQLException e) {
                e.printStackTrace();
        public static void main(String[] args)
                throws java.lang.InterruptedException {
            WriteAntennas runJob = new WriteAntennas();
            runJob.createTable();
            runJob.performLoadWrite();
            runJob.queryRecords();
            runJob.closeConnection();
    }

  • JDBC CLOB error

    Hi,
    I face the following error, i use the oracle jdbc driver as db driver and i use the same ojdbc14.jar file as the project library, but when i try to cast the clob object return from resutlset it throw me class cast exception, i did print out the class name it shown oracle.sql.CLOB, but when i cast the object to oracle.sql.CLOB it still show me the error.
    Do you have any idea what is wrong?
    ====================// java code
    import java.sql.Clob;
    import oracle.sql.CLOB;
    Clob clob = null;
    if ( resultSet.next() )
    clob = resultSet.getClob( 1 );
    logger.debug( "resultSet.getClass() is " + resultSet.getClass() );
    logger.debug( "clob.getClass() is " + clob.getClass() );
    logger.debug( "clob is " + clob );
    logger.debug( "(clob instanceof oracle.sql.CLOB) is " + (clob instanceof oracle.sql.CLOB));
    CLOB oraClob = (CLOB)clob; // this is where the class cast exception occur
    ====================// log file
    [10/01/2005 15:51:26] b.crrs.common.CRRSParamServlet -- DEBUG -- selectUpdateStatement is [email protected]d5b222
    [10/01/2005 15:51:26] b.crrs.common.CRRSParamServlet -- DEBUG -- resultSet.getClass() is class oracle.jdbc.driver.OracleResultSetImpl
    [10/01/2005 15:51:26] b.crrs.common.CRRSParamServlet -- DEBUG -- clob.getClass() is class oracle.sql.CLOB
    [10/01/2005 15:51:26] b.crrs.common.CRRSParamServlet -- DEBUG -- clob is oracle.sql.CLOB@1a21321
    [10/01/2005 15:51:26] b.crrs.common.CRRSParamServlet -- DEBUG -- (clob instanceof oracle.sql.CLOB) is false
    [10/01/2005 15:51:26] b.crrs.common.CRRSParamServlet -- DEBUG -- error
    java.lang.ClassCastException

    See JDBC error for CLOB

  • OCCI Clob.write problem

    hi
    i am new to occi
    i have tested my application and insert data to my tables ;
    I have a field in my table which its type is clob and a procedure for inserting in that table
    when i test procedure with stmt.setString (for the clob field) I have no problem for inserting
    but when using stmt->setClob , there is exception ora-22275
    my code is like this:
    Clob C(conn);
    C.setEmpty();
    C.write(4,"test",4);
    stmt->setClob(1,C);
    stmt->executeUpdate();
    whats wrong?
    error message is about problem in occi::clob::write

    Hi,
    Because LOBs use what are known as locators, you can't just create the clob in client code like that and insert it into the database.
    The database won't "know about" the locator and will raise the ORA-22275 error (as you have discovered).
    What you need to do is initialize the clob as noted in the Clob Class documentation notes. See here for example:
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28390/reference009.htm#i1118691
    An uninitialized CLOB object can be initialized by:
    * The setEmpty() method. The CLOB can then be modified by inserting this CLOB into the table and retrieving it using SELECT ... FOR UPDATE....
    < emphasis added >
    So, essentially, you set the clob to empty, insert it into the table, then using "select for update" you get the clob (locator) back. You need to use "select for update" and not just a regular select. You can then modify the empty clob (be sure to commit when done).
    For an example of this, see the Oracle 10g Release 1 Demos from here:
    http://www.oracle.com/technology/sample_code/tech/occi/index.html
    Regards,
    Mark

  • Problem using CLOB in JDBC (NewLOBAPISample)

    I've just tried to run the JDBC NewLOBAPISample, and everything works fine until I try to insert or update on the CLOB column using any characters other than base ASCII. For example, if I attempt to insert the String "$100", it works just fine, but "£100" results in:
    java.sql.SQLException: No more data to read from socket
    I've experimented with this issue with a much smaller test case of my own, and I've been able to narrow down the problem, as I've outlined below. In all cases, PreparedStatement is used for executing.
    Let's say we have a table named "Test" with one CLOB column named "text".
    The original "official" API for inserting a CLOB using the latest 1.4 JDBC Oracle thin driver is:
    // first insert an "empty CLOB"
    PreparedStatement ps;
    ps = con.prepareStatement("INSERT INTO Test (text) VALUES (empty_clob())");
    ps.executeUpdate();
    // then select the empty CLOB
    con.setAutoCommit(false);
    ps = con.prepareStatement("SELECT text FROM Test FOR UPDATE");
    ResultSet rs = ps.executeQuery();
    rs.next();
    CLOB clob = ((OracleResultSet)rs).getCLOB(1);
    // now write to the CLOB
    Writer out = clob.getCharacterOutputStream();
    out.write(myLongText);
    out.close();
    // we're done
    connection.commit();
    The method that is advertised in NewLOBAPISample, and which I've also seen on the Java Developer Forum, is outlined here:
    // first, create statement to insert
    PreparedStatement ps;
    ps = con.prepareStatement("INSERT INTO Test (text) VALUES (?)");
    // create a temporary CLOB and write to it
    CLOB clob = CLOB.createTemporary(con, true, CLOB.DURATION_SESSION);
    Writer out = clob.getCharacterOutputStream();
    out.write(myLongText);
    // set the CLOB on the PreparedStatement and execute
    ps.setClob(1, clob);
    ps.executeUpdate();
    Now, in the above two cases, if "myLongText" has any characters in it besides standard alpha-numerics, the latter approach will fail, although the former (original) approach will still work. In my case, I need to save Danish characters in the CLOB data. (I can't type these characters in this message, as for some reason they are being converted to "æ å ø" during posting, instead of the letters I've typed on my keyboard.)
    Here is a stack trace when I try the createTemporary approach with a short String that contains one or more non-standard characters:
    java.io.IOException: No more data to read from socket
         at oracle.jdbc.dbaccess.DBError.SQLToIOException(DBError.java:716)
         at oracle.jdbc.driver.OracleClobWriter.flushBuffer(OracleClobWriter.java:270)
         at oracle.jdbc.driver.OracleClobWriter.close(OracleClobWriter.java:232)
    Here's the strack trace when the insert String contains only ONE character that is non-standard:
    java.sql.SQLException: No more data to read from socket
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
         at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:1160)
         at oracle.jdbc.ttc7.MAREngine.unmarshalUB1(MAREngine.java:963)
         at oracle.jdbc.ttc7.MAREngine.unmarshalSB1(MAREngine.java:893)
         at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:369)
         at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
         at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
         at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
         at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
    Any help with this would be MUCH appreciated.
    Thanks,
    David Karlton

    hi David,
    i tried inserting non-alphanumeric chars but still it goes thru fine.
    here is what i did,
    create table testlob ( id number(5),lobcol clob);
    LobInJava.java
    import java.sql.*;
    import oracle.jdbc.*;
    import oracle.sql.*;
    class LobInJava
    public static void main(String args[]) throws Exception
    DriverManager.registerDriver(new
    oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection
    ("jdbc:oracle:thin:@host:1522:ora9idb", "scott", "tiger");
    StringBuffer myLongText = new StringBuffer("nm{H$ñVmZ".length() * 10 );
    for(int i=0 ;i < 1000 ;i++ )
    myLongText.append("nm{H$ñVmZ");
    System.out.println( myLongText.length());
    PreparedStatement ps;
    ps = conn.prepareStatement("INSERT INTO Testlob (id,lobcol) VALUES (2,empty_clob())");
    ps.executeUpdate();
    // then select the empty CLOB
    conn.setAutoCommit(false);
    ps = conn.prepareStatement("SELECT lobcol FROM Testlob where id=2 FOR UPDATE");
    ResultSet rs = ps.executeQuery();
    rs.next();
    CLOB clob = ((OracleResultSet)rs).getCLOB(1);
    // now write to the CLOB
    java.io.Writer out = clob.getCharacterOutputStream();
    out.write(myLongText.toString());
    out.close();
    // we're done
    conn.commit();
    ps.close();
    // first, create statement to insert
    PreparedStatement ps;
    ps = conn.prepareStatement("INSERT INTO Testlob (id,lobcol) VALUES (1,?)");
    // create a temporary CLOB and write to it
    CLOB clob = CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION);
    java.io.Writer out = clob.getCharacterOutputStream();
    out.write(myLongText.toString());
    out.close();
    // set the CLOB on the PreparedStatement and execute
    ps.setClob(1, clob);
    ps.executeUpdate();
    ps.close();
    conn.close();
    i am using jdk 1.3 and Oracle9i v9.0.1
    Regards
    Elango.

  • How to update oracle Oracle by using JDBC

    Mostly we used and still using the following way, as well as it was recommended by oracle official document.
    String empty_string = "need to be updated";
    conn = getConnection();
    pStmt = conn.prepareStatement("SELECT REFERENCE FROM activity WHERE ID = ? FOR UPDATE");
    pStmt.setLong(1, 1);
    rset = pStmt.executeQuery();
    Clob clob = null;
    while (rset.next()) { 
    clob = rset.getClob(1);
    Writer writer = adapter.getCharacterOutputStream(clob);
    writer.write(empty_string);
    writer.flush();
    writer.close();
    pStmt = conn.prepareStatement("update activity set REFERENCE = ? WHERE ID = ?");
    pStmt.setClob(1, clob);
    pStmt.setLong(2, 1);
    pStmt.executeUpdate();
    Now I want use the second way as below, to be honest I never used it before so I wonder can it work properly? as it did not require an explicit lock. will it bring potential risk? according your experience if it work well, which did better performance?
    1. String toBeUpdated = "need to be updated";
    2. StringReader clob = new StringReader(toBeUpdated );
    3. pStmt = conn.prepareStatement("update activity set REFERENCE = ? WHERE ID = ?");
    4. pStmt.setCharacterStream(1, clob, toBeUpdated.length());
    5. pStmt.setLong(2, 1);
    6. pStmt.executeUpdate();

    Welcome to the vast OTN forums!
    If you are asking about jdbc specifically, perhaps the relevant forum is: {forum:id=1050}.
    If what you really are asking is something like (without java code and context):
    "I used to do Select.. for update, followed by update table .... Can I instead use only update table ... ? When and why would you use one or the other?"
    Then this forum might be ok, but the SQL and PL/SQL forum might be even better: {forum:id=75}

  • Retrieving clob locator

    I am having trouble retrieving a clob locator from a column despite being able to set it in a previous statement. The clob is always returned as null.
    This happens to both an 8.1.6 and 8.1.7 with the latest classes12.zip
    Thanks,
    -elliott
    Here is my code snippet:
    oracle.sql.CLOB clob = null;
    // Select LOB locator into standard result set.
    StringBuffer sSelect = new StringBuffer();
    sSelect.append("SELECT " + mercColName + " FROM BUG" + whereClause.toString() + "FOR UPDATE");
    debug.println("Get Clob: " + sSelect.toString());
    ResultSet rs =
    stmt.executeQuery(sSelect.toString());
    while (rs.next()) {
    // Get LOB locator into Java wrapper classes.
    try {
    clob = (oracle.sql.CLOB) rs.getClob(1);
    catch (Exception ex) {
    //do nothing
    if (clob == null)
    //update row
    StringBuffer sUpdateClob = new StringBuffer();
    sUpdateClob.append("UPDATE BUG SET " + mercColName + " = (empty_clob()) " + whereClause.toString());
    debug.println("Update Clob: " + sUpdateClob.toString());
    stmt.execute(sUpdateClob.toString());
    m_DelayConnection.commit();
    ResultSet rs2 =
    stmt.executeQuery(sSelect.toString());
    while (rs2.next()) {
    // Get LOB locator into Java wrapper classes.
    clob = (oracle.sql.CLOB) rs2.getObject(1);
    java.io.Writer writer;
    // read data into a character array
    char[] data = pval.toCharArray();
    // write the array of character data to a CLOB
    writer = clob.getCharacterOutputStream();

    Found the problem. I was using the ODBC driver instead of the JDBC driver.

  • Urgent JBO-26041: Failed to post data to database during (in insert Clob)

    HI ,
    we have a code to get the clob and then write it to the database
    HttpSession session = UIServices.getHttpSession(context);
    byte] payloadByteArray = (byte[)session.getAttribute("FILE_BYTES_fileName");
    String payloadStr = null;
    try {
    //get the string
    payloadStr = new String(payloadByteArray, "UTF-8");
    // System.out.println("---payloadstr --->>>>"+payloadStr) ;
    ClobDomain cd =new ClobDomain(payloadStr);
    XhubRoutingRulesAMImpl am = (XhubRoutingRulesAMImpl)Jbo.getApplicationModule(context);
    SnwRoutingRulesVOImpl SnwRoutingRulesVO= (SnwRoutingRulesVOImpl) am.findObject("SnwRoutingRulesVO");
    Jbo.applyViewCriteriaOneRow(SnwRoutingRulesVO,"RoutingRuleId",routingRuleId);
    SnwRoutingRulesVO.executeQuery();
    SnwRoutingRulesVORowImpl row=null;
    while (SnwRoutingRulesVO.hasNext())
    row =(SnwRoutingRulesVORowImpl) SnwRoutingRulesVO.next();
    row.setPreXslt(cd);
    row.setOverridexslt("Y");
    row.setPostXslt(null);
    //commiting the data
    Jbo.commit(am);
    session.removeAttribute("FILE_BYTES_fileName");
    catch(Exception e){
    e.printStackTrace();
    session.removeAttribute("FILE_BYTES_fileName");
    THE exception are :
    oracle.jbo.DMLException: JBO-26041: Failed to post data to database during "Update": SQL Statement "null".
    at oracle.jbo.server.EntityImpl.doDMLWithLOBs(EntityImpl.java:8139)
    at oracle.jbo.server.EntityImpl.doDML(EntityImpl.java:7994)
    at oracle.apps.snw.schema.server.WhoEntityImpl.doDML(WhoEntityImpl.java:200)
    at oracle.jbo.server.EntityImpl.postChanges(EntityImpl.java:6319)
    at oracle.jbo.server.DBTransactionImpl.doPostTransactionListeners(DBTransactionImpl.java:3168)
    at oracle.jbo.server.DBTransactionImpl.postChanges(DBTransactionImpl.java:2976)
    at oracle.jbo.server.DBTransactionImpl.commitInternal(DBTransactionImpl.java:2014)
    at oracle.jbo.server.DBTransactionImpl.commit(DBTransactionImpl.java:2273)
    at oracle.apps.snw.uicommon.Jbo.commit(Jbo.java:148)
    at oracle.apps.snw.tpadmin.webui.TPRouteRulesEvent.fileUpload(TPRouteRulesEvent.java:241)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at oracle.cabo.servlet.event.MethodEventHandler.handleEvent(Unknown Source)
    at oracle.cabo.data.jbo.servlet.event.ChainingEventHandler.handleEventImpl(Unknown Source)
    at oracle.cabo.data.jbo.servlet.event.FindRootAppModuleEventHandler.handleEventImpl(Unknown Source)
    at oracle.cabo.data.jbo.servlet.event.BaseEventHandler.handleEvent(Unknown Source)
    at oracle.cabo.servlet.event.TableEventHandler.handleEvent(Unknown Source)
    at oracle.cabo.servlet.event.TableEventHandler.handleEvent(Unknown Source)
    at oracle.cabo.data.jbo.xml.parse.JboParserExtensionImpl$SynchronizingEventHandler.handleEvent(Unknown Source)
    at oracle.cabo.servlet.event.BasePageFlowEngine.handleRequest(Unknown Source)
    at oracle.cabo.servlet.AbstractPageBroker.handleRequest(Unknown Source)
    at oracle.cabo.servlet.ui.BaseUIPageBroker.handleRequest(Unknown Source)
    at oracle.cabo.servlet.PageBrokerHandler.handleRequest(Unknown Source)
    at oracle.cabo.servlet.UIXServlet.doGet(Unknown Source)
    at oracle.cabo.servlet.BajaServlet.doGet(Unknown Source)
    at oracle.cabo.servlet.UIXServlet.doPost(Unknown Source)
    at oracle.cabo.servlet.BajaServlet.doPost(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:159)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.dms.wls.DMSServletFilter.doFilter(DMSServletFilter.java:326)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3592)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2202)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2108)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1432)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused by: java.lang.NullPointerException
    at oracle.jbo.domain.ClobDomain.writeCharsToLob(ClobDomain.java:1322)
    at oracle.jbo.domain.ClobDomain.saveToDatabase(ClobDomain.java:464)
    at oracle.jbo.server.EntityImpl.doDMLWithLOBs(EntityImpl.java:8114)
    ... 49 more
    This same code is running fine sometime and we didnt get any issue but sometime it is throwing the error .Its very strange

    EDIT: Nevermind you're using ClobDomain. I was thinking of standard jdbc CLOB's.
    Edited by: Jan Nawara on May 5, 2010 10:35 AM

  • Display clob?

    How do I display the content out of a clob?
    I just got some strange numbers like this...
    oracle.jdbc.driver.OracleClobWriter@68693890
    oracle.sql.CLOB@74b73890
    How do I display the information in my clob and not the binary
    output.
    The code looks like...
              // Set the clob values
              Clob clob = ((OracleResultSet)rsResult).getClob
    (19);
              InputStream is_my_clob = clob.getAsciiStream();
              byte first = (byte)(is_my_clob.read());
              out.println( "FIRST BYTE: " + first + "<BR>");
              Reader char_stream = clob.getCharacterStream();
              char [] char_array = new char [10];
              int chars_read = char_stream.read (char_array,
    0, 10);
              //Reader char_stream = clob.getCharacterStream();
              //char [] char_array = new char [10];
              //int chars_read = char_stream.read (char_array,
    0, 10);
              java.io.Writer writer;
              // read data into a character array
              char[] data =
    {'0','1','2','3','4','5','6','7','8','9'};
              // write the array of character data to a CLOB
              writer = ((CLOB)clob).getCharacterOutputStream();
              //writer.write(data);
              out.println(writer + "<BR>");
              out.println(clob + "<BR>");
              out.println(chars_read);
              writer.flush();
              writer.close();
    Please help me!

    Hi ,
    What you had been trying is like
    CLOB clob = rset.getClob(19);
    System.out.println(clob.toString());
    To display a CLOB, first read the clob data into a StringBuffer
    and then use it.
    StringBuffer clobdata = new StringBuffer();
    // Open the CLOB in READONLY mode
    Reader clobReader = p_Clob.getCharacterStream();
    // Get optimal buffer size
    char[] charbuffer = new char[p_Clob.getBufferSize()];
    // Read from the CLOB and write into the StringBuffer
    while((bytesread=clobReader.read(charbuffer))!= -1)
    clobdata.append(charbuffer,0,bytesread);
    // Close the CLOB and Reader
    // Use the CLOB data
    clobdata.toString();
    Regards
    Elango

  • JDBC Drviers and Linux

    What driver should I use for O8.1.6 using RedHat 6.2 Linux
    Thanks
    P.S. Please respond to [email protected]

    the jdbc driver readme file:
    Oracle JDBC Drivers release 8.1.7 README
    ========================================
    What Is New In This Release?
    These are the major new features/enhancements in this release:
    - Statement Caching
    * Implicit Statement Caching
    * Explicit Statement Caching
    - Full XA Support
    * Including XA Recover and Forget
    * OracleXid independent implementation for 8.1.7 servers and above
    - Connection Caching
    * New Scheme (FIXED_WAIT_SCHEME)
    * Statement Caching coupling
    - PLSQL Tables Support for Scalar types (for OCI driver only)
    - User-Defined Datatypes Performance Enhancement
    - Object Types Extensions
    * Serializable Type Descriptors
    * Accessing collection elements in Java primitive types
    * Buffering and indexing collection elements
    * Creating empty Lobs
    - Support for 56-bit encryption algorithms for connection using
    the Thin JDBC driver.
    These are the major bug fixes:
    - BUG-903011
    The JDBC Thin driver could not be used with usernames that
    contained Latin-1 characters when the server used UTF8 character
    set. This problem has been fixed in release 8.1.7.
    - BUG-1052489
    There was a problem with PreparedStatements being executed
    multiple times and the length of one of the bind variables (bound
    with setBinaryStream or setCharacterStream) increased. This
    problem has been fixed in release 8.1.7.
    - BUG-1069768
    There was a problem with insertion of ADTs with an image bigger
    than 4K with the JDBC Thin driver. This problem has been fixed
    in release 8.1.7.
    - BUG-1247015
    When using ResultSet::getObject() to access CHAR or VARCHAR columns
    in scrollable result sets, ResultSet::getObject() returned null.
    - BUG-1349713
    getString() of scrollable result sets returns incorrect values if
    the column data contains multibyte characters.
    Driver Versions
    These are the driver versions in the 8.1.7 release:
    - JDBC OCI Driver 8.1.7
    Client-side JDBC for use on a machine where OCI 8.1.7 is installed.
    - JDBC Thin Driver 8.1.7
    100% Java client-side JDBC for use in applets and applications.
    - JDBC Thin Server-side Driver 8.1.7
    JDBC for use by Java Stored Procedures or by Java CORBA objects
    running in Oracle 8.1.7. This driver is typically used in a middle
    tier server.
    - JDBC Server-side Internal Driver 8.1.7
    Server-side JDBC for use by Java Stored procedures or by Java CORBA
    objects running in Oracle 8.1.7. This driver used to be called the
    "JDBC Kprb Driver".
    For complete documentation, please refer to "JDBC Developer's Guide
    and Reference".
    Contents Of This Release
    The [ORACLE_HOME]/jdbc/lib directory contains:
    - classes111.zip
    Classes for use with JDK 1.1.x. It contains the JDBC driver
    classes except classes necessary for NLS support in Object and
    Collection types.
    - nls_charset11.zip
    NLS classes for use with JDK 1.1.x. It contains classes necessary
    for NLS support in Object and Collection types.
    - classes111_g.zip
    Same as classes111.zip, except that classes were compiled with
    "javac -g".
    - classes12.zip
    Classes for use with JDK 1.2.x. It contains the JDBC driver
    classes except classes necessary for NLS support in Object and
    Collection types.
    - nls_charset12.zip
    NLS classes for use with JDK 1.2.x. It contains classes necessary
    for NLS support in Object and Collection types.
    - classes12_g.zip
    Same as classes12.zip, except that classes were compiled with
    "javac -g".
    Note that the packaging of the JDBC classes to support NLS was
    changed in 8i. The classes pertaining to specific character sets
    support in Object and Collection types have been separated from the
    basic zip files. These NLS classes are now packaged into the
    extension zip files. This allows the user to include the NLS
    classes only if necessary. Please refer to the "NLS Extension Zip
    Files (for client-side only)" for further details.
    [ORACLE_HOME]/lib directory contains libocijdbc8.so and
    libocijdbc8_g.so (on Solaris), which are the shared libraries used by
    the JDBC OCI driver.
    [ORACLE_HOME]/jdbc/doc/javadoc.tar contains the JDBC Javadoc. This
    release contains a beta release of the Javadoc files for the public
    API of the public classes of Oracle JDBC.
    [ORACLE_HOME]/jdbc/demo/demo.tar contains sample JDBC programs.
    Demo programs written for JDK 1.1 must be modified to run in JDK 1.2.
    Please refer to the "Support For JDK 1.2" for porting details.
    NLS Extension Zip Files (for client-side only)
    The JDBC Server-side Internal Driver provides complete NLS support.
    It does not require any NLS extension zip files, nls_charset*.zip.
    Discussions in this section do not apply to the JDBC Server-side
    Internal Driver. You can skip this section if you only use the
    Server-side Internal Driver.
    The basic zip files, classes111.zip and classes12.zip, contain all the
    necessary classes to provide complete NLS support for:
    - Oracle Character sets for CHAR/VARCHAR/LONGVARCHAR/CLOB type data
    that is not retrieved or inserted as a data member of an Oracle 8
    Object or Collection type.
    - NLS support for CHAR/VARCHAR data members of Objects and
    Collections for a few commonly used character sets. These
    character sets are: US7ASCII, WE8DEC, WE8ISO8859P1 and UTF8.
    Users must include the appropriate extension zip in their CLASSPATH
    if utilization of other character sets in CHAR/VARCHAR data members
    of Objects/Collections is desired. It is important to note that
    extension zip files are large in size due to the requirement of
    supporting a large number of character sets. Users may choose to
    include only the necessary classes from the extension zip file.
    To do so, users can first unzip the extension zip file, and then put
    only the necessary classes in the CLASSPATH. The character set
    extension class files are named in the following format:
    CharacterConverter<OracleCharacterSetId>.class
    where <OracleCharacterSetId> is the hexidecimal representation of the
    Oracle character set id of the corresponding character set.
    Installation
    Please do not try to put multiple versions of the Oracle JDBC drivers
    in your CLASSPATH. The Oracle installer installs the JDBC Drivers in
    the [ORACLE_HOME]/jdbc directory.
    Setting Up Your Environment
    On Win95/Win98/NT:
    - Add [ORACLE_HOME]\jdbc\lib\classes111.zip and
    [ORACLE_HOME]\jdbc\lib\nls_charset11.zip to your CLASSPATH.
    (Add classes12.zip and nls_charset12.zip if JDK 1.2.x is used.)
    - Add [ORACLE_HOME]\jdbc\lib to your PATH.
    On Solaris/Digital Unix:
    - Add [ORACLE_HOME]/jdbc/lib/classes111.zip and
    [ORACLE_HOME]/jdbc/lib/nls_charset11.zip to your CLASSPATH.
    (Add classes12.zip and nls_charset12.zip if JDK 1.2.x is used.)
    - Add [ORACLE_HOME]/jdbc/lib to your LD_LIBRARY_PATH.
    On HP/UX:
    - Add [ORACLE_HOME]/jdbc/lib/classes111.zip and
    [ORACLE_HOME]/jdbc/lib/nls_charset11.zip to your CLASSPATH.
    (Add classes12.zip and nls_charset12.zip if JDK 1.2.x is used.)
    - Add [ORACLE_HOME]/jdbc/lib to your SHLIB_PATH and LD_LIBRARY_PATH.
    On AIX:
    - Add [ORACLE_HOME]/jdbc/lib/classes111.zip and
    [ORACLE_HOME]/jdbc/lib/nls_charset11.zip to your CLASSPATH.
    (Add classes12.zip and nls_charset12.zip if JDK 1.2.x is used.)
    - Add [ORACLE_HOME]/jdbc/lib to your LIBPATH and LD_LIBRARY_PATH.
    Some Useful Hints In Using the JDBC Drivers
    Please refer to "JDBC Developer's Guide and Reference" for details
    regarding usage of Oracle's JDBC Drivers. This section only offers
    useful hints. These hints are not meant to be exhaustive.
    These are a few simple things that you should do in your JDBC program:
    1. Import the necessary JDBC classes in your programs that use JDBC.
    For example:
    import java.sql.*;
    import java.math.*;
    2. Register the Oracle driver before before calling other JDBC APIs.
    (This is not needed if you are using the JDBC Server-side Internal
    Driver because registration is done automatically in the server.)
    To register the Oracle driver, make sure the following statement
    is executed at least once in your Java session:
    DriverManager.registerDriver(
    new oracle.jdbc.driver.OracleDriver());
    3. Open a connection to the database with the getConnection call.
    Different connection URLs should be used for different JDBC
    drivers. The following examples demonstrate the different URLs.
    For the JDBC OCI8 Driver:
    Connection conn = DriverManager.getConnection(
    "jdbc:oracle:oci8:@<database>",
    "scott", "tiger");
    where <database> is either an entry in tnsnames.ora or a SQL*net
    name-value pair.
    For the JDBC Thin Driver, or Server-side Thin Driver:
    Connection conn = DriverManager.getConnection(
    "jdbc:oracle:thin:@<database>",
    "scott", "tiger");
    where <database> is either a string of the form
    <host>:<port>:<sid> or a SQL*net name-value pair.
    For the JDBC Server-side Internal Driver:
    Connection conn = DriverManager.getConnection(
    "jdbc:oracle:kprb:");
    Note that the trailing ':' character is necessary. When you use
    the Server-side Internal Driver, you always connect to the
    database you are executing in. You can also do this:
    Connection conn
    = new oracle.jdbc.driver.OracleDriver().defaultConnection();
    Java Stored Procedures
    Please note that examples for callins and instance methods using Oracle
    8 Object Types are provided in:
    [ORACLE_HOME]/javavm/demo/demo.zip
    Once unzipped, the directory containing the examples is:
    [ORACLE_HOME]/javavm/demo/examples/jsp
    Known Problems/Limitations In This Release
    The following is a list of known problems/limitations:
    1. There is a limitation regarding the use of stream input for LOB
    types. Stream input for LOB types can only be used for 8.1.7
    JDBC OCI driver connecting to an 8.1.7 Oracle server. The use of
    stream input for LOB types in all other configurations may result
    in data corruption. PreparedStatement stream input APIs include:
    setBinaryStream(), setAsciiStream(), setUnicodeStream(),
    setCharacterStream() and setObject().
    2. BUG-1018797
    Extra characters may be appended to the end of a CLOB value
    mistakenly under the following conditions:
    - setCharacterStream() is used to insert a CLOB value, and
    - The Oracle server uses multi-byte character set.
    (See 1 for limitation of stream input for LOB type.)
    3. Programs can fail to open 16 or more connections using our
    client-side drivers at any one time. This is not a limitation
    caused by the JDBC drivers. It is most likely that the limit of
    per-process file descriptors is exceeded. The solution is to
    increase the limit.
    4. The Server-side Internal Driver has the following limitation:
    - Data access for LONG and LONG RAW types is limited to 32K of
    data.
    - Inserts of Object Types (Oracle 8 Objects, Collections and
    References) will not work when the database compatibility mode
    is set to 8.0. This limitation does not apply when the
    compatibility mode is set to 8.1.
    - Statement.cancel() is not implemented.
    - In a chain of SQLExceptions, only the first one in the chain
    will have a getSQLState value.
    5. The JDBC OCI driver on an SSL connection hangs when the Java
    Virtual Machine is running in green threads mode. A work-around
    is to run the Java Virtual Machine in native threads mode.
    6. Date-time format, currency symbol and decimal symbols are always
    presented in American convention.
    7. When using OracleStatement.defineColumnType(), it is not necessary
    to define the column type to be the same as the column type
    declared in the database. If the types are different, the
    retrieved values are converted to the type specified in
    defineColumnType.
    Note: Most reasonable conversions work, but not all. If you find
    a conversion that you think is reasonable, but that does not wo rk,
    please submit a TAR to Oracle Support.
    8. The utility dbms_java.set_output or dbms_java.set_stream that is
    used for redirecting the System.out.println() in JSPs to stdout
    SHOULD NOT be used when JDBC tracing is turned on. This is
    because the current implementation of dbms_java.set_output and
    set_stream uses JDBC to write the output to stdout. The result
    would be an infinite loop.
    9. The JDBC OCI and Thin drivers do not read CHAR data via binary
    streams correctly. In other word, using getBinaryStream() to
    retrieve CHAR data may yield incorrect results. A work-around is
    to use either getCHAR() or getAsciiStream() instead. The other
    alternative is to use getUnicodeStream() although the method is
    deprecated.
    10. BUG-899078 (since 8.1.6 SDK):
    The JDBC Server-side Internal driver has extra space padding with
    PL/SQL CHAR OUT (2 to 3 space depending on character set).
    Problem occurs in most of the multibyte database character set
    except UTF8.
    11. There is a limitation for Triggers implemented in Java and Object
    Types. It only affects the IN argument types of triggers
    implemented using Java on the client-side. The restriction does
    not apply to JDBC programs running inside the server. Triggers
    implemented as Java methods cannot have IN arguments of Oracle 8
    Object or Collection type. This means the Java methods used to
    implement triggers cannot have arguments of the following types:
    - java.sql.Struct
    - java.sql.Array
    - oracle.sql.STRUCT
    - oracle.sql.ARRAY
    - oracle.jdbc2.Struct
    - oracle.jdbc2.Array
    - any class implementing oracle.jdbc2.SQLData or
    oracle.sql.CustomDatum
    12. The scrollable result set implementation has the following
    limitation:
    - setFetchDirection() on ScrollableResultSet is not supported.
    - refreshRow() on ScrollableResultSet does not support all
    combinations of sensitivity and concurrency. The following
    table depicts the supported combinations.
    Support Type Concurrency
    no TYPE_FORWARD_ONLY CONCUR_READ_ONLY
    no TYPE_FORWARD_ONLY CONCUR_UPDATABLE
    no TYPE_SCROLL_INSENSITIVE CONCUR_READ_ONLY
    yes TYPE_SCROLL_INSENSITIVE CONCUR_UPDATABLE
    yes TYPE_SCROLL_SENSITIVE CONCUR_READ_ONLY
    yes TYPE_SCROLL_SENSITIVE CONCUR_UPDATABLE
    13. BUG-1324918
    Repeatedly updating a clob with jdbc-oci, prepared statement,
    and setCharacterStream consumes the temporary tablespace. If
    you repeatedly update the clob, either the temp tablespace will
    continue to grow, or you may get a Exception in thread "main"
    java.sql.SQLException: ORA-01652: unable to extend segment if
    you have a limit on the tablespace size. The work-around is to
    use oracle.sql.CLOB::setCharacterOutputStream() instead.

  • Multiple select queries for JDBC sender

    I am working on JDBc to IDOC scenario.
    I need to process two select queries in PI where output of 1st query becomes the input of second.
    Now i need to map the output of second to IDOC through XSL mapping also i need to use BPM to process(without using the stored procedure) the scenario.
    In my JDBC communication channel i have option for only one select query and second query should fetch the data through BPM.
    In BPM i have used the following sequence mentioned below:
    Start --> Receive step ( receives all the header lines) --> Transformation (to split the header messages to single message) --> Block Start( To processEachRecord) --> Send Syn (to map the request message i,e. output of first query with Response i,e. structure of the second query)  --> Send Asyn (to send the output of second query to XSLT mapping) -->Block End --> stop
    Output of XSLT mapping is the input for IDOC
    Now i need to understand how to process the second query?

    >> I need to process two select queries in PI where output of 1st query becomes the input of second
    Use SQL Nested Queries. 
    Example:
    SELECT Model FROM Product WHERE ManufacturerID IN (SELECT ManufacturerID FROM Manufacturer
    WHERE Manufacturer = 'Dell')
    Here first table is Manufacturer .. we do select query in manufacturer to return data and pass it to the first table Product.
    >> Now i need to understand how to process the second query?
    You dont need at all. In your sender jdbc channel, write sql statement nested query and you will get only output of the second table. you map the second table output to the idoc.
    Note: Dont know why do you need BPM for this case..
    Jdbc sender adapter  help links
    http://help.sap.com/saphelp_srm40/helpdata/en/7e/5df96381ec72468a00815dd80f8b63/content.htm
    Check this thread for update statement in jdbc cc
    Re: sender jdbc adapter

  • JDBC Sender adapter question

    Hi,
    Scenario: JDBC-XI-R/3
    I am trying to run the JDBC sender adapter every 3 minutes based on the poll interval to select rows from Oracle db.
    In the select and update statements when I use the rownum < '11' and flag condition (Y or N), then I see XI is picking up 10 rows in a two times and I see two parallel processes in SXMB_MONI.
    I want XI to run only pickup 10 rows for every 3 minutes and update only 10 rows in Oracle to "N" from "Y".
    When I take out the rownum condition from update I do not see this issue.
    <u>Update statement:</u>
    Update <TABLE> set status_flag = 'N' WHERE status_flag = 'Y' and rownum < '11'.
    Can some body point me in the right direction ?
    Thanks
    Steve

    Hi there,
    See if this works. Though I never came across such a scenario, I can think what to be done in this case.
    Create a staging table as same structure as from where our JDBC adapter is picking up the data currently.
    Whrite a tigger(after delete) on staging table to call a stored procedure.
    stored procedure will select the data from source table and insert them in to staging table (rownum<11) as well as update the flag column in source table.
    Now load the staging table initially from source table with only 10 rows (one time process). Configure your JDBC adapter on staging table. In update sqlquery field of JDBC adapter write delete statement for all the data from staging table to be purged, as there will not be more than 10 rows at any time and after each time the adapter supplied Delete statement will purge the data so you dont have to worry about selecting 10 rows or updating 10 rows from JDBC adapter. As every time the trigger after delete statement will fire and load only 10 rows from source marking those 10 rows as read_already status.
    NOTE: for Calling stored procedure from trigger follow your database SQL reference documentation.
    Thanks.
    -Nilkanth.

  • JDBC Sender Adapter Message format

    I am somenone who is new to SAP PI so please help me out in the format of datatype for JDBC SENDER Adapter ?

    Hi Rajesh
    The source xml structure for JDBC adapter is like below
    <resultset>
    <row>
    <column-name1>column-value</ column-name1>
    <column-name2>column-value</ column-name2>
    <column-name3>column-value</ column-name3>
    </row>
    <row>
    <column-name1>column-value</ column-name1>
    <column-name2>column-value</ column-name2>
    <column-name3>column-value</ column-name3>
    </row>
    </resultset>
    Then in the sender JDBC adapter, write the select and update query
    SQL statement for query: SELECT * FROM table WHERE processed = 0;
    SQL statement for update: UPDATE table SET processed = 1 WHERE processed = 0;
    processed is the indicator in the database.
    Check this link for details
    https://help.sap.com/saphelp_nw04/helpdata/en/7e/5df96381ec72468a00815dd80f8b63/content.htm

  • Read a txt file make it a clob

    Hello. I have a text file that I'd like to read and then set the contents to a clob value. I'm really not too familar with streams and buffers, so everything I've tried has been grasping at straws.
    I've tried reading the file with a fileReader object then writing it a string and trying to convert string to clob... no go
    FileReader frObject = new FileReader("d:\\jrun4\\servers\\test\\Ndadsbload1.txt");
    BufferedReader brObject = new BufferedReader(frObject);
    String line = brObject.readLine();
    String sFile = "";
    Clob clob;
    while (line != null) {
    sFile += line;
    line = brObject.readLine();
    I've read on clobs, and saw some on ascii streams, but I'm kinda stuck. Can anyone help me out?

    Thanks alot. That seems to make some sense to me. I am getting an error though. I have nothing on the page but your code, and I thought the Clob clob; would have prevented this. Am I correct in thinking that the var clob will contain the contents of the file at the completion of the loop? Again, I really appreciate the help you've already given and any additional you can give regarding this error.
    192.      Writer clobWriter = clob.setCharacterStream(0);
    <--->
    *** Error: The variable "clob" may be accessed here before having been definitely assigned a value.
    The code again:
    FileReader frObject = new FileReader("d:\\jrun4\\servers\\test\\test\\Ndadsbload1.txt");
    BufferedReader brObject = new BufferedReader(frObject);
    String line = null;
    String sFile = "";
    Clob clob;
    Writer clobWriter = clob.setCharacterStream(0);
    PrintWriter pw = new PrintWriter(clobWriter);
    while ((line = brObject.readLine()) != null){ 
    pw.println(line);
    }

Maybe you are looking for