Jdbc thin driver and bulk binding slow insertion performance

Hello All,
We have a third party application reporting slow insertion performance, while I traced the session and found out most of elapsed time for one insert execution is sql*net more data from client, it appears bulk binding is being used here because one execution has 200 rows inserted. I am wondering whether this has something to do with their jdbc thin driver(10.1.0.2 version) and our database version 9205. Do you have any similar experience on this, what other possible directions should I explore?
here is the trace report from 10046 event, I hide table name for privacy reason.
Besides, I tested bulk binding in PL/SQL to insert 200 rows in one execution, no problem at all. Network folks confirm that network should not be an issue as well, ping time from app server to db server is sub milisecond and they are in the same data center.
INSERT INTO ...
values
(:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17,
:18, :19, :20, :21, :22, :23, :24, :25, :26, :27, :28, :29, :30, :31, :32,
:33, :34, :35, :36, :37, :38, :39, :40, :41, :42, :43, :44, :45)
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.02 14.29 1 94 2565 200
Fetch 0 0.00 0.00 0 0 0 0
total 2 0.02 14.29 1 94 2565 200
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 25
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net more data from client 28 6.38 14.19
db file sequential read 1 0.02 0.02
SQL*Net message to client 1 0.00 0.00
SQL*Net message from client 1 0.00 0.00
********************************************************************************

I have exactly the same problem, I tried to find out what is going on, changed several JDBC Drivers on AIX, but no hope, I also have ran the process on my laptop which produced a better and faster performance.
Therefore I made a special solution ( not practical) by creating flat files and defining the data as an external table, the oracle will read the data in those files as they were data inside a table, this gave me very fast insertion into the database, but still I am looking for an answer for your question here. Using Oracle on AIX machine is a normal business process followed by a lot of companies and there must be a solution for this.

Similar Messages

  • Jdbc thin driver bulk binding slow insertion performance problem

    Hello All,
    We have a third party application reporting slow insertion performance, while I traced the session and found out most of elapsed time for one insert execution is sql*net more data from client, it appears bulk binding is being used here because one execution has 200 rows inserted. I am wondering whether this has something to do with their jdbc thin driver(10.1.0.2 version) and our database version 9205. Do you have any similar experience on this, what other possible directions should I explore?
    here is the trace report from 10046 event, I hide table name for privacy reason.
    Besides, I tested bulk binding in PL/SQL to insert 200 rows in one execution, no problem at all. Network folks confirm that network should not be an issue as well, ping time from app server to db server is sub milisecond and they are in the same data center.
    INSERT INTO ...
    values
    (:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17,
    :18, :19, :20, :21, :22, :23, :24, :25, :26, :27, :28, :29, :30, :31, :32,
    :33, :34, :35, :36, :37, :38, :39, :40, :41, :42, :43, :44, :45)
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 1 0.02 14.29 1 94 2565 200
    Fetch 0 0.00 0.00 0 0 0 0
    total 2 0.02 14.29 1 94 2565 200
    Misses in library cache during parse: 1
    Optimizer goal: CHOOSE
    Parsing user id: 25
    Elapsed times include waiting on following events:
    Event waited on Times Max. Wait Total Waited
    ---------------------------------------- Waited ---------- ------------
    SQL*Net more data from client 28 6.38 14.19
    db file sequential read 1 0.02 0.02
    SQL*Net message to client 1 0.00 0.00
    SQL*Net message from client 1 0.00 0.00
    ********************************************************************************

    I have exactly the same problem, I tried to find out what is going on, changed several JDBC Drivers on AIX, but no hope, I also have ran the process on my laptop which produced a better and faster performance.
    Therefore I made a special solution ( not practical) by creating flat files and defining the data as an external table, the oracle will read the data in those files as they were data inside a table, this gave me very fast insertion into the database, but still I am looking for an answer for your question here. Using Oracle on AIX machine is a normal business process followed by a lot of companies and there must be a solution for this.

  • JDBC thin driver and Oracle 8.1.6

    Hi,
    I have installed Oracle 8.1.6 on Windows NT 4.0 with service pack 4 and using Oracle JDBC thin driver driver (classes111.zip). My application is multithreaded, but each thread maintains its own connection (and own set of Statements). Things are okay in single threaded mode, but in multi threaded mode, I get weird errors!
    1. My resultsets are SCROLL_SENTITIVE and UPDATABLE
    2. Sometimes, while updating a row, "No current row" SQLException is thrown, although a row exists that satisfies my select criteria
    3. I am also calling executeUpdate() for inserting new rows and such rows are not seen by successive resultsets!
    Appreciate any hints! Thanks!

    Try this isntead.
    java -classpath d:\jdbc\classes12.zip;. jdbccheckup
    an error occured:
    Exception in thread "main" java.lang.NoClassDefFoundError:jdbccheckup
    Why??????

  • Oracle JDBC Thin Driver and Firewall Problem

    Hi!
    We have Oracle 8.1.5 and Websphere App Server. There is a
    firewall between the two. A servlet creates a connection pool
    (not that of Wesphere's). The frontend is JSP/HTML (no applets).
    The servlet uses the Oracle JDBC Thin Driver for DB Connections.
    The problem is - Once the connection is freed, the connection
    pool is not being able to retrieve it and hence it created
    another one, thus reaching the max. # of connections and the
    system hangs. Restarting the DB service flushes the connection
    and the application starts running again...
    There was a similar problem discussed in this forums long ago. I
    have not yet tried mentioning the firwall port and IP in the
    connection string. But apart from that, is there any other
    setting I need to do (on firewall or for the connectionstring)
    to deal with this problem?
    Someone had suggested to punch a hole in the firewall for the DB
    port - but we can not really do that in the current scenario...
    I would appreciate if anyone could share their experience
    regarding how they resolved this issue.
    Thanks in advance,
    Vijaya.

    One more question -
    Can we use Oracle JDBC OCI driver? We do not have any appletes...
    Does it have firewall issues too? Is there any other driver that
    we can use?
    Thanks,
    Vijaya.

  • JDBC Thin-Driver and Oracle Stored Procedure

    I've got a Oracle stored procedure which returns a Oracle record.
    How can I retrieve the record in java using the JDBC Thin-Driver ?
    Record:
    TYPE messagerec IS RECORD
    (log_level VARCHAR(2), timestamp VARCHAR2(19), text VARCHAR2(200));

    Using PL/SQL BOOLEAN, RECORD Types, and TABLE Types:
    Oracle SQLJ and JDBC do not support calling arguments or return values of the
    PL/SQL BOOLEAN type or RECORD types. Also, when using the Thin driver, they
    do not support calling arguments or return values of PL/SQL TABLE types (known
    as indexed-by tables). TABLE types are supported for the OCI driver.
    Check the following guide,
    http://otn.oracle.com/tech/java/sqlj_jdbc/pdf/a96655.pdf

  • JDBC Thin driver and Oracle names server

    Hi
    Any managed to get the Thin driver to user the Names Server aliases, ie I want to connect to service xxx like
    jdbc:oracle:thin:@xxxx and not specify instance and port as the DB is running in a multiple machine cluster and can be switched to a different machine...
    With OCI driver I have managed on NT but having problem with OCI/Linux and Beta 10g...
    Tks
    Andre

    I don't have much experience with OCI from JDBC, but should work like any other kind of connection via SQL*Net. I.e. I would check if connection can be made using SQLPlus, check environment variables (ORACLE_HOME etc.) of 9iAS instance, check version of JDBC classes and their readme.txt. There are also some settings in sqlnet.ora file which might affect this (like default domain - try to use full name of alias - OCRL.WORLD or whatever alias you have there). You may also want to switch tracing for SQLNet and/or listener on (it's not easy to find in doc how to do it, though) to check if there is at least some traffic between klient and server...
    Myrra

  • Oracle Jdbc Thin driver and nls suppot

    Hello,
    I have a hungarian database with nls_lang variable set to hungarian. I'm trying to do a jdbc connection using classes12.zip
    but I'm getting the hungarian characters converted to question marks or other characters.
    I read suggestions that I must include the nls_charset12.zip in my classpath too. So I did that but I'm still having the same problem.
    What is missed??
    How do I get the right hungarian charachters without any conversion.
    This is becoming frustrating and I'm not able to solve it yet.
    Thanks for your help

    One more question -
    Can we use Oracle JDBC OCI driver? We do not have any appletes...
    Does it have firewall issues too? Is there any other driver that
    we can use?
    Thanks,
    Vijaya.

  • Does oracle 8.1.6.0 jdbc thin driver support jdk1.3 and oracle 8.0.5 database ?

    I have downloaded oracle 8.1.6.0 jdbc thin driver(named classes12.zip) to run with jdk1.3 to access oracle 8.0.5, but when I compile and run the jdbccheckup.java downloaded from oracle website like this:
    javac -classpath d:\jdbc\classes12.zip jdbccheckup.java
    (compile succeed)
    java -classpath d:\jdbc\classes12.zip jdbccheckup
    an error occured:
    Exception in thread "main" java.lang.NoClassDefFoundError:jdbccheckup
    Why??????

    Try this isntead.
    java -classpath d:\jdbc\classes12.zip;. jdbccheckup
    an error occured:
    Exception in thread "main" java.lang.NoClassDefFoundError:jdbccheckup
    Why??????

  • JDBC Thin Driver Support for Data Encryption and Integrity

    Hello JDev Team,
    I am trying to implement JDBC Thin Driver Support for Data Encryption and Integrity.
    It works fine with java.sql.Connection and java.util.Properties like in the following code:
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Properties props = new Properties();
    int level = AnoServices.REQUIRED;
    props.put("oracle.net.encryption_client", Service.getLevelString(level));
    props.put("oracle.net.encryption_types_client", "( RC4_40 )");
    props.put("oracle.net.crypto_checksum_client",Service.getLevelString(level));
    props.put("oracle.net.crypto_checksum_types_client", "( MD5 )");
    Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@localhost:1521:main", props);
    etc...
    But I am developing an application with InfoSwing components and it has a different way to connect to Oracle database using oracle.dacf.dataset.connections.Connection, like this:
    sessionInfo1.setAppModuleInfo(new ModuleInfo("bc", "BcModule"));
    sessionInfo1.setConnectionInfo(new LocalConnection("JDBCThin"));
    sessionInfo1.publishSession();
    My question is:
    Is there any way to implement DataEncryption and Integrity into this type of connection?
    Thanks a lot in advance.
    Victor Bykov
    null

    Victor,
    No, you can't do this from DAC, but I've been discussing it with the developer, and we both think this capability would be useful to have, so I've logged it as an enhancement request.
    I do have a question for you. Once you've made the JDBC connection, do you need access to the Connection object afterwards? We're thinking of how the change could be implemented, and one way would be to allow you to pass in a Properties object when creating your own NamedConnection.
    Thanks
    Blaise

  • Bug in Oracle JDBC thin driver (parameter order)

    [ I'd preferably send this to some Oracle support email but I
    can't find any on both www.oracle.com and www.technet.com. ]
    The following program illustrates bug I found in JDBC Oracle thin
    driver.
    * Synopsis:
    The parameters of prepared statement (I tested SELECT's and
    UPDATE's) are bound in the reverse order.
    If one do:
    PreparedStatement p = connection.prepareStatement(
    "SELECT field FROM table WHERE first = ? and second = ?");
    and then bind parameter 1 to "a" and parameter to "b":
    p.setString(1, "a");
    p.setString(2, "b");
    then executing p yields the same results as executing
    SELECT field FROM table WHERE first = "b" and second = "a"
    although it should be equivalent to
    SELECT field FROM table WHERE first = "a" and second = "b"
    The bug is present only in "thin" Oracle JDBC driver. Changing
    driver to "oci8" solves the problem.
    * Version and platform info:
    I detected the bug using Oracle 8.0.5 server for Linux.
    According to $ORACLE_HOME/jdbc/README.doc that is
    Oracle JDBC Drivers release 8.0.5.0.0 (Production Release)
    * The program below:
    The program below illustrates the bug by creating dummy two
    column table, inserting the row into it and then selecting
    the contents using prepared statement. Those operations
    are performed on both good (oci8) and bad (thin) connections,
    the results can be compared.
    You may need to change SID, listener port and account data
    in getConnecton calls.
    Sample program output:
    $ javac ShowBug.java; java ShowBug
    Output for both connections should be the same
    --------------- thin Driver ---------------
    [ Non parametrized query: ]
    aaa
    [ The same - parametrized (should give one row): ]
    [ The same - with buggy reversed order (should give no answers):
    aaa
    --------------- oci8 driver ---------------
    [ Non parametrized query: ]
    aaa
    [ The same - parametrized (should give one row): ]
    aaa
    [ The same - with buggy reversed order (should give no answers):
    --------------- The end ---------------
    * The program itself
    import java.sql.*;
    class ShowBug
    public static void main (String args [])
    throws SQLException
    // Load the Oracle JDBC driver
    DriverManager.registerDriver(new
    oracle.jdbc.driver.OracleDriver());
    System.out.println("Output for both connections should be the
    same");
    Connection buggyConnection
    = DriverManager.getConnection
    ("jdbc:oracle:thin:@localhost:1521:ORACLE",
    "scott", "tiger");
    process("thin Driver", buggyConnection);
    Connection goodConnection
    = DriverManager.getConnection ("jdbc:oracle:oci8:",
    "scott", "tiger");
    process("oci8 driver", goodConnection);
    System.out.println("--------------- The end ---------------");
    public static void process(String title, Connection conn)
    throws SQLException
    System.out.println("--------------- " + title + "
    Statement stmt = conn.createStatement ();
    stmt.execute(
    "CREATE TABLE bug (id VARCHAR(10), val VARCHAR(10))");
    stmt.executeUpdate(
    "INSERT INTO bug VALUES('aaa', 'bbb')");
    System.out.println("[ Non parametrized query: ]");
    ResultSet rset = stmt.executeQuery(
    "select id from bug where id = 'aaa' and val = 'bbb'");
    while (rset.next ())
    System.out.println (rset.getString (1));
    System.out.println("[ The same - parametrized (should give one
    row): ]");
    PreparedStatement prep = conn.prepareStatement(
    "select id from bug where id = ? and val = ?");
    prep.setString(1, "aaa");
    prep.setString(2, "bbb");
    rset = prep.executeQuery();
    while (rset.next ())
    System.out.println (rset.getString (1));
    System.out.println("[ The same - with buggy reversed order
    (should give no answers): ]");
    prep = conn.prepareStatement(
    "select id from bug where id = ? and val = ?");
    prep.setString(1, "bbb");
    prep.setString(2, "aaa");
    rset = prep.executeQuery();
    while (rset.next ())
    System.out.println (rset.getString (1));
    stmt.execute("DROP TABLE bug");
    null

    Horea
    In the ejb-jar.xml, in the method a cursor is closed, set <trans-attribute>
    to "Never".
    <assembly-descriptor>
    <container-transaction>
    <method>
    <ejb-name></ejb-name>
    <method-name></method-name>
    </method>
    <trans-attribute>Never</trans-attribute>
    </container-transaction>
    </assembly-descriptor>
    Deepak
    Horea Raducan wrote:
    Is there a known bug in Oracle JDBC thin driver version 8.1.6 that would
    prevent it from closing the open cursors ?
    Thank you,
    Horea

  • Oracle JDBC Thin Driver

    I am using CLOBS with the Oracle thin driver and am experiencing horrible performance. We need datavalues more than a VARCHAR2 and have used CLOB but the method Oracle uses to get the data in and out is super slow.
    MS SQL Server JDBC with text is awesome and fast. But Oracle is slow and very cumbersome.
    Help

    We are using 9.0.2.
    So what you are saying is although the column is CLOB
    in Oracle 10 g we can use a normal result set
    rset.getString( 1 ) no special oracle stuff just the
    e Oracle thin driver for 10g?
    Also this will retrieve a String greater than 4000
    bytes?Exactly. Not only you can retieve a clob as string, you can also insert clob
    as a string too. Here is the code I referred in last post in case you do not
    have access to oracle ten network:
    * @author Savitha
    * @version 1.0
    * Development Environment : Oracle JDeveloper 10g
    * Name of the Application : ClobManipulationIn10g.java
    * Creation/Modification History :
    * Savitha 17-Mar-2004 Created.
    package oracle.otnsamples.jdbc;
    // Java SQL classes
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.Statement;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    // Oracle JDBC driver class
    import oracle.jdbc.OracleDriver;
    // Java IO classes
    import java.io.IOException;
    import java.io.BufferedReader;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    //Java Util classes
    import java.util.Properties;
    * This class demonstrates the Oracle JDBC 10g enhanced features for inserting
    * and retrieving CLOB data from the database. Using the new features, large
    * data of more than 32765 bytes can be inserted into the database using the
    * existing PreparedStatement.setString() and PreparedStatement.getString()
    * methods.
    public class ClobManipulationIn10g {
    /* Database Connection object */
    private Connection conn = null;
    /* Variables to hold database details */
    private String url = null;
    private String user = null;
    private String password = null;
    // Create a property object to hold the username, password and
    // the new property SetBigStringTryClob.
    private Properties props = new Properties();
    /* String to hold file name */
    private String fileName = null;
    * Default Constructor to instantiate and get a handle to class methods
    * and variables.
    public ClobManipulationIn10g(String fileName) {
    this.fileName = fileName;
    * Main runnable class.
    public static void main(String[] args) throws SQLException {
    // Instantiate the main class.
    ClobManipulationIn10g clobManipulationIn10g =
    new ClobManipulationIn10g(args[0]);
    // Load the Oracle JDBC driver class.
    DriverManager.registerDriver(new OracleDriver());
    // Load the database details into the variables.
    String dbUrl = "jdbc:oracle:thin:@<database host machine>:<port>:<SID>";
    clobManipulationIn10g.url = dbUrl;
    // Replace the username where the table 'clob_tab' was created.
    clobManipulationIn10g.user = "scott";
    // Replace the password of the username.
    clobManipulationIn10g.password = "tiger";
    // Populate the property object to hold the username, password and
    // the new property 'SetBigStringTryClob' which is set to true. Setting
    // this property allows inserting of large data using the existing
    // setString() method, to a CLOB column in the database.
    clobManipulationIn10g.props.put("user", clobManipulationIn10g.user );
    clobManipulationIn10g.props.put("password", clobManipulationIn10g.password);
    clobManipulationIn10g.props.put("SetBigStringTryClob", "true");
    // Check if the table 'CLOB_TAB' is present in the database.
    clobManipulationIn10g.checkTables();
    // Call the methods to insert and select CLOB from the database.
    clobManipulationIn10g.insertClob();
    clobManipulationIn10g.selectClob();
    * This method will insert the data into a CLOB column in the database.
    * Oracle JDBC 10g has enhanced the existing PreparedStatement.setString()
    * method for setting the data more than 32765 bytes. So, using setString(),
    * it is now easy to insert CLOB data into the database directly.
    private void insertClob() throws SQLException {
    // Create a PreparedStatement object.
    PreparedStatement pstmt = null;
    try {
    // Create the database connection, if it is closed.
    if ((conn==null)||conn.isClosed()){
    // Connect to the database.
    conn = DriverManager.getConnection( this.url, this.props );
    // Create SQL query to insert data into the CLOB column in the database.
    String sql = "INSERT INTO clob_tab VALUES(?)";
    // Read a big file(larger than 32765 bytes)
    String str = this.readFile();
    // Create the OraclePreparedStatement object
    pstmt = conn.prepareStatement(sql);
    // Use the same setString() method which is enhanced to insert
    // the CLOB data. The string data is automatically transformed into a
    // clob and inserted into the database column. Make sure that the
    // Connection property - 'SetBigStringTryClob' is set to true for
    // the insert to happen.
    pstmt.setString(1,str);
    // Execute the PreparedStatement
    pstmt.executeUpdate();
    } catch (SQLException sqlex) {
    // Catch Exceptions and display messages accordingly.
    System.out.println("SQLException while connecting and inserting into " +
    "the database table: " + sqlex.toString());
    } catch (Exception ex) {
    System.out.println("Exception while connecting and inserting into the" +
    " database table: " + ex.toString());
    } finally {
    // Close the Statement and the connection objects.
    if (pstmt!=null) pstmt.close();
    if (conn!=null) conn.close();
    * This method reads the CLOB data from the database by using getString()
    * method.
    private void selectClob() throws SQLException {
    // Create a PreparedStatement object
    PreparedStatement pstmt = null;
    // Create a ResultSet to hold the records retrieved.
    ResultSet rset = null;
    try {
    // Create the database connection, if it is closed.
    if ((conn==null)||conn.isClosed()){
    // Connect to the database.
    conn = DriverManager.getConnection( this.url, this.props );
    // Create SQL query statement to retrieve records having CLOB data from
    // the database.
    String sqlCall = "SELECT clob_col FROM clob_tab";
    pstmt= conn.prepareStatement(sqlCall);
    // Execute the PrepareStatement
    rset = pstmt.executeQuery();
    String clobVal = null;
    // Get the CLOB value from the resultset
    while (rset.next()) {
    clobVal = rset.getString(1);
    System.out.println("CLOB length: "+clobVal.length());
    } catch (SQLException sqlex) {
    // Catch Exceptions and display messages accordingly.
    System.out.println("SQLException while connecting and querying the " +
    "database table: " + sqlex.toString());
    } catch (Exception ex) {
    System.out.println("Exception while connecting and querying the " +
    "database table: " + ex.toString());
    } finally {
    // Close the resultset, statement and the connection objects.
    if (rset !=null) rset.close();
    if (pstmt!=null) pstmt.close();
    if (conn!=null) conn.close();
    * Method to check if the table ('CLOB_TAB') exists in the database; if not
    * then it is created.
    * Table Name: CLOB_TAB
    * Column Name Type
    * col_col CLOB
    private void checkTables() {
    Statement stmt = null;
    ResultSet rset = null;
    try {
    // Create the database connection, if it is closed.
    if ((conn==null)||conn.isClosed()){
    // Connect to the database.
    conn = DriverManager.getConnection( this.url, this.props );
    // Create Statement object
    stmt = conn.createStatement();
    // Check if the table is present
    rset = stmt.executeQuery(" SELECT table_name FROM user_tables "+
    " WHERE table_name = 'CLOB_TAB' ");
    // If the table is not present, then create the table.
    if (!rset.next()) {
    // Table does not exist, create it
    stmt.executeUpdate(" CREATE TABLE clob_tab(clob_col CLOB)");
    } catch (SQLException sqlEx) {
    System.out.println("Could not create table clob_tab : "
    +sqlEx.toString());
    } finally {
    try {
    if( rset != null ) rset.close();
    if( stmt != null ) stmt.close();
    if (conn!=null) conn.close();
    } catch(SQLException ex) {
    System.out.println("Could not close objects in checkTables method : "
    +ex.toString());
    * This method reads the specified text file and, returns the content
    * as a string.
    private String readFile()
    throws FileNotFoundException, IOException{
    // Read the file whose content has to be passed as String
    BufferedReader br = new BufferedReader(new FileReader(fileName));
    String nextLine = "";
    StringBuffer sb = new StringBuffer();
    while ((nextLine = br.readLine()) != null) {
    sb.append(nextLine);
    // Convert the content into to a string
    String clobData = sb.toString();
    // Return the data.
    return clobData;
    }

  • JDBC thin driver pads CHAR col to byte size when NLS_LENGTH_SEMANTICS=CHAR

    We're using an Oracle 9.2 database with the database character set specified as AL32UTF8 with NLS_LENGTH_SEMANTICS set to CHAR. I've reproduced this problem with both the "classes12.zip" and "ojdbc14.jar" available with the Oracle 9.2 client installation.
    The problem occurs with the JDBC thin driver. The problem does not occur with the JDBC OCI driver (nor SQL*Plus 9.2).
    There are 2 relatively simply workarounds: use the OCI driver or convert CHAR columns to VARCHAR2 columns. I'm mostly curious as to whether there is some kind of setting for the thin driver to circumvent this problem, or if this is actually expected behavior. We're not that familiar with the NLS_LENGTH_SEMANTICS setting.
    Consider a table as follows:
    create table my_table (status CHAR(1));
    If I describe the table it correctly shows the column using CHAR semantics.
    STATUS CHAR(1 CHAR)
    Given the AL32UTF8, this means that 4 bytes of storage are reserved for this column.
    If I insert a single ASCII character in this table (for example "A") then read it back using the JDBC thin driver, I get the string "A " - the letter A followed by 3 spaces. In other words, the thin driver appears to have padded the value to its BYTE length. The OCI driver and SQL*Plus do not pad the value.
    I understand that CHAR columns are normally blank padded when the data size is shorter than the defined column length, but I think that with NLS_LENGTH_SEMANTICS=CHAR, the padding should be based on the length of the column in chars, not in bytes.
    Can anyone shed some light on this issue?
    Thanks in advance,
    Tim

    Update:
    I guess I should mention we're using Java 2 SDK 1.4.1_01 on Windows XP with an Oracle 9.2 database on Windows 2000.

  • JDBC Thin Client and Oracle Long Datatype

    I am using Wepshere 4.0.2 , JDBC 2.0 (thin driver) and oracle 9i.
    I have a procedure which takes Oracle Long Datatype as its parameter.
    I use following code to execute procedure.
    String dataforsql="AAA000000003 123123 07/01/200301/01/2003";
    byte[] bytes = dataforsql.getBytes();
    InputStream is = new ByteArrayInputStream(bytes);
    cstmt=conn.prepareCall("call nscw.CPPF_SAVEPDCRAWTABLE2(?,?,?)");
    cstmt.setAsciiStream (1, is,bytes.length);
    The above code works perfectly for data upto 4000 bytes. Once the data crosses the 4000 mark.
    i get a procedure error
    ORA-01460: unimplemented or unreasonable conversion requested

    cstmt.setAsciiStream (1, is,bytes.length);Oracle's support for CLOB (and BLOB) columns using set{Ascii,Binary}Stream() generally s*cks. You'll have to read Oracle's own JDBC manual (you can read it online at http://technet.oracle.com) for whatever sequence they recommend.
    E.g. for insertion and updation of CLOBS, you're supposed to use an oracle-specific function (EMPTY_CLOB()) as the value in the INSERT/UPDATE statement, and then do a SELECT, getClob(), and use Clob APIs to update the actual column value. At least officially. Or you have to use some Oracle-specific APIs in oracle.sql.Connection and oracle.sql.CLOB.

  • Problems with jdbc thin driver (Euro Symbol)

    Hello,
    at the moment it is impossible for me to write or read euro characters to a database using a jdbc thin driver.
    I am using
    ojdbc14.jar (version 10.2.0.3.0) and orai18n.jar (also) together with JDK 1.4.2.
    Charset of the database is WE8MSWIN1252. It does not work on ORACLE 9.2.0.1, 9.2.0.6 and 10.2.0.2.0 (others I have not tried). But the problem seams to be in thin client.
    Inserting Eurosymbols using a PreparedStatement works quite well. Using a normal Statement does not work.
    Also the values getting from a ResultSet are incorrect.
    After several test I downloaded a patch 4659157 for ojdbc14.jar and 5470375 for orai18n.jar. After installing the patch the euro characters were returned, but:
    In several selects of numeric fields (not all, seams to be random) my resultset returned the Euro character instead of 0 and so on.
    Driver for 9.2 works quite well, but does not support 10g Release 2 (and contains also some funny bugs)
    Following solutions are not suitable for us:
    Changing the character set of the database (come on, this cannot be serious. I cannot change the character set of more than 100 databases)
    Using the newest driver (ORACLE 11). We are still using JAVA 1.4.2 and cannot migrate our application at the moment.
    Using an oci client. Not possible, no ORACLE client on clients...
    Has anyone an idea how to deal with this?
    Does anyone know when ORACLE is going to release a new jdbc driver for JAVA 1.4.2 (maybe 10.2.0.4.) ??
    Regards,
    Christian

    Just installed PATCH 4659157 and 5470375 from metalink. The Euro problem seams to be corrected.
    BUT:
    Another problem occurred. Sometimes numeric values are returned wrong (0 from a numeric field comes as euro, 1 comes as Á (2 and 3 too).
    This error seams to be random to me.
    Our application is selecting a rowid from a table and after that fills several textfields in a frame by selecting the content in a way like this:
    select [column1] from [table] where rowid=[rowid]
    select [column2] from [table] where rowid=[rowid]
    if I select the numeric column with select nr. 77 I get a wrong value. If I select it at nr. 10 I get the correct value.
    The selects are done by a normal Statement object creating a ResultSet. The Value from the ResultSet is fetched by getObject() method.
    I also tried to write a test program executing only the selects of the application, but it gives me correct results.
    Also when selecting all the fields in one select I get a correct result.
    Using a different charset than WE8MSWIN1252 seams to give correct results. Using the OCI driver returns correct results.
    Using ojdbc14.jar and orai18n.jar Release 10.2.0.3. unpatched produces the same error (and does not return Euro symbols)
    Using ojdbc14.jar and orai18n.jar Release 10.2.0.2. returns correct results (but wrong Euro)
    Has anyone had the same problem yet?
    Regards,
    Christian

  • Error Code Definition for JDBC Thin driver

    Would like to know where I can find the definition of error codes
    for JDBC thin driver to Oracle 7 database. Right now, when I have
    database errors, I get SQL execption with CODE=XXXXXX. Need to
    know the definition of the error codes in order to decide whether
    the application shall retry or quit or do something else. Thank
    you in advance.
    null

    Hi,
    thin client session Language is controlled by java Locale.
    Based on testing code, ORA- messages are localized after the connection is successfully established. ORA- messages returned in the middle of connecting are in instance language.
    So, as far as I can say, you need to catch exceptions from DriverManager.getConnection(url, info); and translate them on your own.
    Once the connection is successfully returned, ORA- message language is defined by java Locale.
    Tests were performed on Oracle 10gR2 (both thin driver and DB).

Maybe you are looking for