SQLException Handling

I am writing a program which wants to capture the unique constraint violation error when an insertion is performed.
I think I can do so by checking the value of the exception.getErrorCode() when an SQLException. However, how do I know which value to check for? And, where can I get a list of the error codes for Oracle database?
Really appreciate your help.
Thanks in advance,
SiowLing Kong

The errorcode is the exact number of the oracle error code (positive numbers)
eg. 54 = ROWLOCK
You can found the documentation of the errorcodes on the oracle web side, or in the oracle documentation, which is shipped with the installation.
I personaly use the online documentation of the oracle help or
the product SQL*Codes from the webside www.oraxcel.com. This is a winhelp file with all oracle codes inside.
so long
ThK

Similar Messages

  • Eception in thread 'main'

    Hows it going?,
    I, having a problem with a ResultSet which is causing the program to throw the above exception. The code is connecting to an oracle db whcih works fine in college, but when i run teh same code on my laptop (bar changing the db name, and the address) it crashes out.
    The program wont throw an error in i put the resultSet into a while statement when executing a query, but will return null. At the same time im doing a simple insert statement which works fine.... Here is an example of my code,
    //none working code
    //query stuff
    ResultSet rs;
    try {
    db.connect ();
    String sql = "Select * from myTable";
    rs.query ();
    rs.next ();
    str = rs.getString (1);
    System.out.println (str);
    db.close
    catch.........//half working code in that the insert works
    ResultSet rs;
    try {
    db.connect ();
    String sql = "Select * from myTable";
    rs.query ();
    while (rs!=null) {
    rs.next ();
    str = rs.getString (1);
    System.out.println (str);
    db.close
    catch.........
    public void upDate ();
    db.connect ();
    String sql = "insert into myTable values ('Brian')";
    db.update ();
    db.close;
    }any help would be much appreciated.
    Brian

    Your code pattern is flawed.
    Look at your code and consider the following pattern
    local declarations (Connection, Statement, ResultSet ...)
    try{
    initialize the Connection
    initialize the Statement
    execute the query
    test the ResultSet for null state
    while the ResultSet has more records
    fetch data from the current row of the ResultSet and store it someplace you can get to it later
    close the ResultSet, Statement and Connection
    catch(SQLException){
    Handle the exception and do whatever is appropriate
    finally{
    set the ResultSet, Statement and Connection to null
    Done

  • Working with oracle object type tables

    Hi,
    I've created a table which only contains Oracle object types (e.g. CREATE TABLE x OF <...>). When I create an Entity for this table using the Entity wizard, I end up with an entity with the attributes of the base object type and two special attributes REF$ (reference to the object type instance) and SYS_NC_OID$ (unique object identifier). The REF$ attribute is on the Java side of type oracle.jbo.domain.Ref and the other attribute is on the Java side a simple String.
    It seems this only allows me to save objects of the base type in this table. First of all in my situation this is also impossible because the base type is not instantiable. What I do want is to save several different subtypes into this table using the BC4J custom domain mechanism. Is there any way to make this possible? I first thought I could maybe do something with the special REF$ attribute, but this doesn't seem te case. So I might need to override most of the EntityImpl methods, like doUML, remove etc. Am I right? And does anyone have any hints on how to do this?
    Regards,
    Peter

    Peter:
    Hi,
    I've created a table which only contains Oracle
    object types (e.g. CREATE TABLE x OF <...>).
    When I create an Entity for this table using the
    Entity wizard, I end up with an entity with the
    attributes of the base object type and two special
    attributes REF$ (reference to the object type
    instance) and SYS_NC_OID$ (unique object identifier).
    The REF$ attribute is on the Java side of type
    oracle.jbo.domain.Ref and the other attribute is on
    the Java side a simple String.
    It seems this only allows me to save objects of the
    base type in this table. First of all in my situation
    this is also impossible because the base type is not
    instantiable. What I do want is to save several
    different subtypes into this table using the BC4J
    custom domain mechanism. Is there any way to make
    this possible? Sorry, but this is not supported out of the box.
    Since you have an object table, you wouldn't use domains to achieve this. Instead, you would have a superclass and subclass entity objects, e.g., PersonEO subclassed into StudentEO and EmployeeEO.
    I first thought I could maybe do
    something with the special REF$ attribute, but this
    doesn't seem te case. So I might need to override
    most of the EntityImpl methods, like doUML, remove
    etc. Am I right? And does anyone have any hints on
    how to do this?
    If you want, you can try this by overridding EntityImpl's:
       protected StringBuffer buildDMLStatement(int operation,
          AttributeDefImpl[] allAttrs,
          AttributeDefImpl[] retCols,
          AttributeDefImpl[] retKeys,
          boolean batchMode)
    and
       protected int bindDMLStatement(int operation,
          PreparedStatement stmt,
          AttributeDefImpl[] allAttrs,
          AttributeDefImpl[] retCols,
          AttributeDefImpl[] retKeys,
          HashMap retrList,
          boolean batchMode) throws SQLException
    Handle the case when operation == DML_INSERT.
    There, build an insert statement with substitutable row, e.g.:
    INSERT INTO persons VALUES (person_t('Bob', 1234));
    INSERT INTO persons VALUES (employee_t('Joe', 32456, 12, 100000));
    where person_t and employee_t are database types and you are invoking the respective constructor.
    Thanks.
    Sung

  • SQL variable in jdbc

    I'd like to retrieve one result but I have to use @variable in sqls like below.
    1) select @variable := b_id from cp_contents_test where contentid = "8593B9B13A2105B5E252FB11F1FF0822";
    2) select cp_contents_test.b_id,cap_member.mem_name,cap_member.mem_email,ctg_no,
    title,subtitle,summary,keyword,description,imagelink,lname_0,lname_1,lname_2
    ,lurl_0,lurl_1,lurl_2, fname,fsize,down,point,creationDate,ip,hit
    from cp_contents_test,cap_member,links
    where cp_contents_test.mem_no=cap_member.mem_no
    and cp_contents_test.b_id = links.b_id
    and cp_contents_test.b_id=@variable;
    I just like to know how to use those two sql statements in jdbc...
    Is there any specific way to use a variable in jdbc?

    Is there any specific way to use a variable in jdbc?You can use a "?" as a placeholder for a bind variable. You can then use the setXXX methods in the PreparedStatement class to set the value. The same PreparedStatement can be reused by setting new parameter values and re-executing.
    public void runTest(Connection con, long[] ids) {
         PreparedStatement pstmt          = null;
         ResultSet rs               = null;
         long value               = 0;
         // Your SQL Statement
         String sql = "select column1 from table1 where column2 = ?";
         try {
              // Prepare it once
              pstmt = con.prepareStatement(sql);
              // Loop through your criteria...
              int size = ids.length;
              for (int i = 0; i < size; i++) {
                   // Set the parameter value to the current criteria
                   pstmt.setLong(1, ids);
                   // (Re-)Execute the Query
                   rs = pstmt.executeQuery();
                   // Loop through the returned ResultSet...
                   while (rs.next()) {
                        // and get the values
                        value = rs.getLong(1);
                        // Do something with value...
         } catch (SQLException) {
              // Handle Exception
         } finally {
              try {
                   rs.close();
              } catch (Exception e) {}
              try {
                   pstmt.close();
              } catch (Exception e) {}
    It appeared that you were trying to set a parameter as the result of one SQL statement for use in a 2nd SQL statement. You can take a result retrieved in Java in the manner above and feed it to a 2nd PreparedStatement created the same way. However, in the specific example you gave, it appears the 2 queries really could have just been one....The 2nd query could have had cp_contents_test.contentid = "...." in the where clause.

  • Errors installing SOA Suite 11g

    Good morning
    This is an odd error. I am installing a brand new environment for SOA-SUITE 11g on a test database before going through the pain to complete this in our development environment. I am using RCU to build the environment as instructed and am allowing RCU to handle everything but constructing the schemas. I have created the schemas manually via SQL*Plus.
    This process has worked in the past so I'm at a loss for explaining these errors. In creating the SOAINFRA, I am receving the following errors:
    ORA-60019: Creating initial extent of size 14 in tablespace of extent size 13
    ORA-06512: at "SYS.DBMS_AQADM", line 81
    ORA-06512: at line 2
    JDBC SQLException handled by error handler
    2012-06-08 09:09:30.929 rcu:Extracting Statement from File Name: 'D:\rcuHome\rcu\integration\soainfra\sql\fabric\createschema_edndb_oracle.sql'Line Number: 157
    2012-06-08 09:09:30.929 rcu:Extracted SQL Statement: [begin
    DBMS_AQADM.create_queue_table(queue_table=>'edn_oaoo_delivery_table', queue_payload_type=>'edn_oaoo_delivery',
    multiple_consumers=>TRUE);
    DBMS_AQADM.create_queue(queue_name=>'edn_oaoo_queue', queue_table=>'edn_oaoo_delivery_table');
    DBMS_AQADM.start_queue(queue_name=>'edn_oaoo_queue');
    end;
    2012-06-08 09:09:30.929 rcu:Statement Type: 'BEGIN/END Anonymous Block'
    JDBC SQLException - ErrorCode: 60019SQLState:99999 Message: ORA-60019: Creating initial extent of size 14 in tablespace of extent size 13
    ORA-06512: at "SYS.DBMS_AQADM", line 81
    ORA-06512: at line 2
    JDBC SQLException handled by error handler
    2012-06-08 09:09:35.547 rcu:Extracting Statement from File Name: 'D:\rcuHome\rcu\integration\soainfra\sql\fabric\createschema_edndb_oracle.sql'Line Number: 167
    2012-06-08 09:09:35.547 rcu:Extracted SQL Statement: [declare
    sub sys.aq$_agent;
    begin
    sub := sys.aq$_agent('edn_java_subscriber', NULL, NULL);
    DBMS_AQADM.add_subscriber(queue_name=>'edn_event_queue', subscriber=>sub);
    end;
    2012-06-08 09:09:35.547 rcu:Statement Type: 'BEGIN/END Anonymous Block'
    JDBC SQLException - ErrorCode: 24010SQLState:99999 Message: ORA-24010: QUEUE EDN_EVENT_QUEUE does not exist
    ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
    ORA-06512: at "SYS.DBMS_AQADM_SYS", line 6268
    ORA-06512: at "SYS.DBMS_AQADM", line 364
    ORA-06512: at line 5
    JDBC SQLException handled by error handler
    2012-06-08 09:09:35.781 rcu:Extracting Statement from File Name: 'D:\rcuHome\rcu\integration\soainfra\sql\fabric\createschema_edndb_oracle.sql'Line Number: 174
    2012-06-08 09:09:35.781 rcu:Extracted SQL Statement: [declare
    sub sys.aq$_agent;
    begin
    sub := sys.aq$_agent('edn_oaoo_subscriber', NULL, NULL);
    DBMS_AQADM.add_subscriber(queue_name=>'edn_oaoo_queue', subscriber=>sub);
    end;
    2012-06-08 09:09:35.781 rcu:Statement Type: 'BEGIN/END Anonymous Block'
    JDBC SQLException - ErrorCode: 24010SQLState:99999 Message: ORA-24010: QUEUE EDN_OAOO_QUEUE does not exist
    ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
    ORA-06512: at "SYS.DBMS_AQADM_SYS", line 6268
    ORA-06512: at "SYS.DBMS_AQADM", line 364
    ORA-06512: at line 5
    JDBC SQLException handled by error handler
    Now, I thought this was a tablespace space issue but here is a report on the status of all tablespaces.
    Free Space Layout
    Total Max Total
    Number Free Free Available
    Tablespace of Space Space Space Percent
    Name Fragments (Meg) (Meg) (Meg) Free
    EXAMPLE 3 36 33 346 10.271
    SOA_SUITE_DATA_01 1 101 101 101 99.853
    SOA_SUITE_DATA_02 1 101 101 101 99.853
    SYSAUX 114 560 500 1,161 48.272
    SYSTEM 2 503 499 1,241 40.532
    UNDOTBS1 18 40 21 105 37.917
    USERS 2 101 100 106 95.224
    I even granted RESOURCE in case the tool needed UNLIMITED TABLESPACE.
    Does anyone have any ideas here? Any help would be greatly appreciated
    Stephen Karniotis

    Hi Stephen
    "I am using RCU to build the environment as instructed and am allowing RCU to handle everything but constructing the schemas. I have created the schemas manually via SQL*Plus"
    Do you mean you are not running RCU utility command from D:\rcuHome\bin\rcu.cmd folder ? As far as I know, this is the supported and easiest way to create any Schemas for any SOA Middleware product like SOA, BPM, OBIEE, ODI, WebCenter etc etc. I am not sure if directly running sql scripts will work and if its possible also.
    I would prefer running rcu.cmd command and provide Database SYS username, password with db details like db host, port, sid. Incase if db credentials are secret and not given to you, simply ask that DB Adminstrator to run this RCU command. Just unzip this file and run rcu.cmd and provide all the details. This do NOT need any other thing at all. Its pretty straight forward.
    RCU command takes care of all the things. Create tablespaces, schemas, then create all the stuff inicluding tables, sequeneces, packages and compile them also.
    Finally if you use Oracle XE 10g Edition, run one line to set this value before you run rcu.cmd -> set RCU_JDBC_TRIM_BLOCKS=TRUE
    Thanks
    Ravi Jegga

  • Cannot commit during managed transaction

    Using Kodo 2.5.2, JBoss 3.2.1, and the DefaultDS datasource (HSQL)
    provided by JBoss, I'm getting the following exception when calling
    PersistenceManager.makePersistent:
    java.sql.SQLException: You cannot commit during a managed transaction!
    at
    com.solarmetric.kodo.impl.jdbc.runtime.SQLExceptions.throwFatal(SQLEx
    ceptions.java:58)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.SQLExceptions.handle(SQLExcept
    ions.java:43)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.newDataStoreI
    d(JDBCStoreManager.java:562)
    at
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.makePersistentFil
    ter(PersistenceManagerImpl.java:1450)
    at
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.makePersistent(Pe
    rsistenceManagerImpl.java:1380)
    Any idea why?
    -Chris

    Using Kodo's connection pooling fixed the problem.
    Thanks for the help.
    Chris West wrote:
    I suspect JBoss connection pooling could be the problem. A couple of
    questions...
    1. Do you know which versions of JBoss have this problem.
    2. How do I configure Kodo to use it's own connection pool on JBoss?
    -Chris West
    Stephen Kim wrote:
    I would highly suggest using Kodo's connection pool first and see if
    that alleviates the problem. I recall JBoss having some connection pool
    issues in certain versions.
    Steve Kim
    [email protected]
    SolarMetric Inc.
    http://www.solarmetric.com

  • Is it possible to connect OJDBC14.JAR with tomcat?!

    Hello,
    I�m using tomcat and receiving the error bellow ...
    I�m using ojdbc14.jar and I configured the tomcat like this:
    URL: jdbc:oracle:thin:@localhost:1521:xe
    Class: oracle.jdbc.driver.OracleDriver
    There is no problem to visit pages that only show the result of searches... So the problem happend when i try to visit the pages that creates or updates a data base register...
    What is the problem?! Is it possible to connect tomcat and oracleXE DB using ojdbc14.jar?!?
    Please someone....help me
    Gustavo Callou
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    com.sun.rave.web.ui.appbase.ApplicationException: org.apache.jasper.JasperException: java.lang.RuntimeException: java.sql.SQLException: handle de instru��o n�o foi executado: getMetaData
         com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.destroy(ViewHandlerImpl.java:601)
         com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.renderView(ViewHandlerImpl.java:316)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:221)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
         com.sun.rave.web.ui.util.UploadFilter.doFilter(UploadFilter.java:194)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.
    Apache Tomcat/5.5.17

    Hi,
    the problem is that is I little bit dificult to debug with tomcat...
    I have already read:
    http://forum.sun.com/jive/thread.jspa?forumID=123&threadID=63633
    and the marco�s blogs on:
    http://blogs.sun.com/marcoscorner/entry/creator_2_ea_webapps_and
    So I concluded that it is possible to use the ojdbc14.jar of oracle, but I still receiving the getMetaData erro... what am i supose to do?!
    Is it possible to someone send me some example that works fine?!
    Bellow there is a code example that i use to update the data of one row...
    In the development It works fine... but with tomcat using the OJDBC14.jar does not... I�m receiving this:
    com.sun.rave.web.ui.appbase.ApplicationException: org.apache.jasper.JasperException: java.lang.RuntimeException: java.sql.SQLException: handle de instru��o n�o foi executado: getMetaData
    How can I change my code to does not receive this erro anymore with tomcat using OJDBC14.jar version 10.2.0.1.0?!
    public void prerender() {
    try {
    getSessionBean1().getTb_setorRowSet().setObject(1,
    getRequestBean1().getCodigoSetor());
    tb_setorDataProvider.refresh();
    } catch (Exception e) {
    error("Cannot read tracks for " +
    getRequestBean1().getCodigoSetor() +
    ": " + e.getMessage());
    log("Cannot read tracks for " +
    getRequestBean1().getCodigoSetor() + ": ", e);
    public void destroy() {
    tb_setorDataProvider.close();
    public String btn_salvar_action() {
    try {
    tb_setorDataProvider.commitChanges();
    log("update: changes committed");
    info("Opera\347\343o Salva");
    } catch(Exception e) {
    log("update: cannot commit changes ", e);
    error("Cannot commit changes: " + e.getMessage());
    return null;
    Please Marco or anyone help me!!!
    Thanks
    Gustavo

  • RCU-6130:Action failed.RCU-6131:Error while trying to connect to database

    Hi,
    Iam facing issue while installing RCU in UBUNTU, its unable to create MDS schema showing "RCU-6130:Action failed.RCU-6131:Error while trying to connect to database" error.
    Any solutions welcome plz

    2013-03-20 17:53:17.450 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration//mds/sql/mds_user.sql'Line Number: 30
    2013-03-20 17:53:17.450 rcu:Extracted SQL Statement: [CREATE USER &&1 IDENTIFIED BY &&2 DEFAULT TABLESPACE &&3 TEMPORARY TABLESPACE &&4]
    2013-03-20 17:53:17.450 rcu:Statement Type: 'DDL Statement'
    JDBC SQLException - ErrorCode: 1920SQLState:42000 Message: ORA-01920: user name 'DEV_MDS' conflicts with another user or role name
    JDBC SQLException handled by error handler
    2013-03-20 17:53:17.475 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration//mds/sql/mds_user.sql'Line Number: 32
    2013-03-20 17:53:17.475 rcu:Extracted SQL Statement: [GRANT connect TO &&1]
    2013-03-20 17:53:17.475 rcu:Statement Type: 'DDL Statement'
    2013-03-20 17:53:17.542 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration//mds/sql/mds_user.sql'Line Number: 33
    2013-03-20 17:53:17.543 rcu:Extracted SQL Statement: [GRANT create type TO &&1]
    2013-03-20 17:53:17.543 rcu:Statement Type: 'DDL Statement'
    2013-03-20 17:53:17.559 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration//mds/sql/mds_user.sql'Line Number: 34
    2013-03-20 17:53:17.559 rcu:Extracted SQL Statement: [GRANT create procedure TO &&1]
    2013-03-20 17:53:17.559 rcu:Statement Type: 'DDL Statement'
    2013-03-20 17:53:17.576 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration//mds/sql/mds_user.sql'Line Number: 35
    2013-03-20 17:53:17.576 rcu:Extracted SQL Statement: [GRANT create table TO &&1]
    2013-03-20 17:53:17.576 rcu:Statement Type: 'DDL Statement'
    2013-03-20 17:53:17.592 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration//mds/sql/mds_user.sql'Line Number: 36
    2013-03-20 17:53:17.593 rcu:Extracted SQL Statement: [GRANT create sequence TO &&1]
    2013-03-20 17:53:17.593 rcu:Statement Type: 'DDL Statement'
    2013-03-20 17:53:17.609 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration//mds/sql/mds_user.sql'Line Number: 39
    2013-03-20 17:53:17.609 rcu:Extracted SQL Statement: [ALTER USER &&1 QUOTA unlimited ON &&3]
    2013-03-20 17:53:17.610 rcu:Statement Type: 'DDL Statement'
    2013-03-20 17:53:17.634 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration//mds/sql/mds_user.sql'Line Number: 40
    2013-03-20 17:53:17.635 rcu:Extracted SQL Statement: [DECLARE
    cnt NUMBER;
    package_not_found EXCEPTION;
    PRAGMA EXCEPTION_INIT(package_not_found, -00942);
    insufficient_privs EXCEPTION;
    PRAGMA EXCEPTION_INIT(insufficient_privs, -01031);
    BEGIN
    cnt := 0;
    SELECT count(*) INTO cnt FROM dba_tab_privs WHERE grantee = 'PUBLIC'
    AND owner='SYS' AND table_name='DBMS_OUTPUT'
    AND privilege='EXECUTE';
    IF (cnt = 0) THEN
    -- Grant MDS user execute on dbms_output only if PUBLIC
    -- doesn't have the privilege.
    EXECUTE IMMEDIATE 'GRANT execute ON dbms_output TO &&1';
    END IF;
    cnt := 0;
    SELECT count(*) INTO cnt FROM dba_tab_privs WHERE grantee = 'PUBLIC'
    AND owner='SYS' AND table_name='DBMS_LOB'
    AND privilege='EXECUTE';
    IF (cnt = 0) THEN
    -- Grant MDS user execute on dbms_lob only if PUBLIC
    -- doesn't have the privilege.
    EXECUTE IMMEDIATE 'GRANT execute ON dbms_lob TO &&1';
    END IF;
    EXCEPTION
    -- If the user doesn't have privilege to access dbms_* package,
    -- database will report that the package cannot be found. RCU
    -- even doesn't throw the exception to the user, since ORA-00942
    -- is an ignored error defined in its global configuration xml
    -- file.
    WHEN package_not_found THEN
    RAISE insufficient_privs;
    WHEN OTHERS THEN
    RAISE;
    END;
    2013-03-20 17:53:17.635 rcu:Statement Type: 'BEGIN/END Anonymous Block'
    2013-03-20 17:53:17.694 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration//mds/sql/cremds-rcu.sql'Line Number: 27
    2013-03-20 17:53:17.694 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration//mds/sql/cremds-rcu.sql'Line Number: 28
    2013-03-20 17:53:17.694 rcu:Extracted SQL Statement: [SET ECHO ON]
    2013-03-20 17:53:17.694 rcu:Skipping Unsupported Statement
    2013-03-20 17:53:17.694 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration//mds/sql/cremds-rcu.sql'Line Number: 29
    2013-03-20 17:53:17.695 rcu:Extracted SQL Statement: [SET FEEDBACK 1]
    2013-03-20 17:53:17.695 rcu:Skipping Unsupported Statement
    2013-03-20 17:53:17.695 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration//mds/sql/cremds-rcu.sql'Line Number: 30
    2013-03-20 17:53:17.695 rcu:Extracted SQL Statement: [SET NUMWIDTH 10]
    2013-03-20 17:53:17.695 rcu:Skipping Unsupported Statement
    2013-03-20 17:53:17.695 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration//mds/sql/cremds-rcu.sql'Line Number: 31
    2013-03-20 17:53:17.695 rcu:Extracted SQL Statement: [SET LINESIZE 80]
    2013-03-20 17:53:17.695 rcu:Skipping Unsupported Statement
    2013-03-20 17:53:17.695 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration//mds/sql/cremds-rcu.sql'Line Number: 32
    2013-03-20 17:53:17.695 rcu:Extracted SQL Statement: [SET TRIMSPOOL ON]
    2013-03-20 17:53:17.695 rcu:Skipping Unsupported Statement
    2013-03-20 17:53:17.696 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration//mds/sql/cremds-rcu.sql'Line Number: 33
    2013-03-20 17:53:17.696 rcu:Extracted SQL Statement: [SET TAB OFF]
    2013-03-20 17:53:17.696 rcu:Skipping Unsupported Statement
    2013-03-20 17:53:17.696 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration//mds/sql/cremds-rcu.sql'Line Number: 34
    2013-03-20 17:53:17.696 rcu:Extracted SQL Statement: [SET PAGESIZE 100]
    2013-03-20 17:53:17.696 rcu:Skipping Unsupported Statement
    2013-03-20 17:53:17.696 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration//mds/sql/cremds-rcu.sql'Line Number: 35
    2013-03-20 17:53:17.696 rcu:Extracted SQL Statement: [ALTER SESSION SET CURRENT_SCHEMA=&&1]
    2013-03-20 17:53:17.696 rcu:Statement Type: 'DDL Statement'
    2013-03-20 17:53:17.712 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration/mds/sql/cremds.sql'Line Number: 36
    2013-03-20 17:53:17.713 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration/mds/sql/cremds.sql'Line Number: 37
    2013-03-20 17:53:17.713 rcu:Extracted SQL Statement: [SET ECHO ON]
    2013-03-20 17:53:17.713 rcu:Skipping Unsupported Statement
    2013-03-20 17:53:17.713 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration/mds/sql/cremds.sql'Line Number: 38
    2013-03-20 17:53:17.713 rcu:Extracted SQL Statement: [SET FEEDBACK 1]
    2013-03-20 17:53:17.713 rcu:Skipping Unsupported Statement
    2013-03-20 17:53:17.713 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration/mds/sql/cremds.sql'Line Number: 39
    2013-03-20 17:53:17.713 rcu:Extracted SQL Statement: [SET NUMWIDTH 10]
    2013-03-20 17:53:17.713 rcu:Skipping Unsupported Statement
    2013-03-20 17:53:17.714 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration/mds/sql/cremds.sql'Line Number: 40
    2013-03-20 17:53:17.714 rcu:Extracted SQL Statement: [SET LINESIZE 80]
    2013-03-20 17:53:17.714 rcu:Skipping Unsupported Statement
    2013-03-20 17:53:17.714 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration/mds/sql/cremds.sql'Line Number: 41
    2013-03-20 17:53:17.714 rcu:Extracted SQL Statement: [SET TRIMSPOOL ON]
    2013-03-20 17:53:17.714 rcu:Skipping Unsupported Statement
    2013-03-20 17:53:17.714 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration/mds/sql/cremds.sql'Line Number: 42
    2013-03-20 17:53:17.714 rcu:Extracted SQL Statement: [SET TAB OFF]
    2013-03-20 17:53:17.714 rcu:Skipping Unsupported Statement
    2013-03-20 17:53:17.714 rcu:Extracting Statement from File Name: '/obiapps/RCU/rcuHome/rcu/integration/mds/sql/cremds.sql'Line Number: 43
    2013-03-20 17:53:17.715 rcu:Extracted SQL Statement: [SET PAGESIZE 100]
    2013-03-20 17:53:17.715 rcu:Skipping Unsupported Statement
    /obiapps/RCU/rcuHome/rcu/integration/mds/sql/cremdcmtbs.sql (No such file or directory)

  • Java.sql.SQLException: statement handle not executed

    hello,
    i am calling a stored procedure and its returns a REF CURSOR and i am getting intermittent exceptions below,
    org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [{call
    xxxx_pkg(?,?)}]; SQL state [99999]; error code [17144]; statement handle not executed; nested exception is java.sql.SQLException: statement handle not executed
    and
    org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [{call
    xxxx_pkg(?,?,?)}]; SQL state [99999]; error code [17009]; Closed Statement; nested exception is java.sql.SQLException: Closed Statement
    any clue what could be the issue,
    Regards
    GG

    its pretty simple have a java class calling hibernateTemplate's findByNamedQueryAndNamedParam method by passing the procedure name and binding parameters/values, and here is the stack
    org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [{call
    xxx_pkg(?,?)}]; SQL state [99999]; error code [17144]; statement handle not executed; nested exception is java.sql.SQLException: statement handle not executed
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
    at org.springframework.orm.hibernate3.HibernateAccessor.convertJdbcAccessException(HibernateAccessor.java:424)
    at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:410)
    at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
    at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
    at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedQueryAndNamedParam(HibernateTemplate.java:1006)
    Caused by: java.sql.SQLException: statement handle not executed
    at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
    at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:112)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:173)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:229)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:403)
    at oracle.jdbc.driver.T4CStatement.doDescribe(T4CStatement.java:701)
    at oracle.jdbc.driver.OracleStatement.getColumnIndex(OracleStatement.java:3355)
    at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:2009)
    at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:494)
    at org.hibernate.type.StringType.get(StringType.java:18)
    at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:163)
    at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:154)
    at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)
    at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2091)
    at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1380)
    at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1308)
    at org.hibernate.loader.Loader.getRow(Loader.java:1206)
    at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:580)
    at org.hibernate.loader.Loader.doQuery(Loader.java:701)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
    at org.hibernate.loader.Loader.doList(Loader.java:2217)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2108)
    at org.hibernate.loader.Loader.list(Loader.java:2103)
    at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
    at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1696)
    at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
    at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
    at org.springframework.orm.hibernate3.HibernateTemplate$34.doInHibernate(HibernateTemplate.java:1015)
    at org.springframework.orm.hibernate3.HibernateTemplate$34.doInHibernate(HibernateTemplate.java:1)
    at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)

  • Handling SQLExceptions

    Hi,
    I have an interesting problem. In my ctor of a Creator JSP page, after the built-in initialization for a rowSet, I call some innocent SQL like so:
    attributeRowSetForListbox.setInt( 1, PRODUCT_ID);
    attributeRowSetForListbox.setString( 2, "f");
    attributeRowSetForListbox.execute();
    The listbox is bound to the rowset via Creator and this works fine when the query succeeds.
    But when the query fails, I get an SQLException that says:
    java.sql.SQLException: Illegal operation on empty result set.
    Fine.
    The problem is that this Exception is printed to the log, but it is NOT executed in my code - the catch block for my try never gets called!!!! It is as if the call to execute() is asynchronous and always succeeds, but real SQL failures (SQLExceptions) are posted (say from another thread) to the log but not in my code. If this is true, then do I need to register an exception listener, much like is done in JMS. If so, what is the registration method?
    HOWEVER - If this is NOT the case, and execute() is supposed to operate synchronously (i.e., from the thread that invoked it), then we have a bigger problem...
    TIA for your help.

    Thanks, sure thing. Of course we can see that MySQL is throwing the exception (perhaps innapropriately, perhaps not) but one problem is that my jsp page redirects to the same page and I can't figure out how to control the program flow from that point - perhaps it is a JSF technique I am unaware of? Or a setting in the App server I can toggle?
    Even if I could, it's not really an error... BTW, I've seen the other postings regarding this issue.
    Anyway:
    CODE:
    attributeRowSetForListbox.setInt( 1, PRODUCT_ID);
    attributeRowSetForListbox.setString( 2, "f");
    attributeRowSetForListbox.execute();
    attributeRowSetForListbox.commit();
    if ( attributeRowSetForListbox.next())
    // then there are more than zero rows.
    this.log( mPageName + " attributeRowSetForListbox should have some rows");
    else
    // handle EMPTY ROWSET HERE. (not in the catch block.)
    this.log( mPageName + " attributeRowSetForListbox should be empty, done with this Product!");
    final String AFTER_MSG = " ctor; <<SUCCESS>> Gathered all Attributes for product - " + PRODUCT;
    this.log( mPageName + AFTER_MSG);
    catch ( Exception e)
    final String FAILURE_MSG = " ctor; <<FAILED>> to gather all Attributes for product - " + PRODUCT;
    this.log( mPageName + FAILURE_MSG);
    final String ERR_MSG = mPageName
    + " <<FAILED>> ctor; Exception occurred ****!! : " + e.getMessage();
    this.log( ERR_MSG);
    LOG:
    [#|2005-02-14T17:46:33.375-0700|INFO|sun-appserver-pe8.0.0_01|javax.enterprise.system.container.web|_ThreadID=12;|WebModule[/tas_user_webapp][TasNewInventoryPage] attributeRowSetForListbox should be empty, done with this Product!|#]
    [#|2005-02-14T17:46:33.375-0700|INFO|sun-appserver-pe8.0.0_01|javax.enterprise.system.container.web|_ThreadID=12;|WebModule[/tas_user_webapp][TasNewInventoryPage] ctor; <<SUCCESS>> Gathered all Attributes for product - -1:|#]
    [#|2005-02-14T17:46:33.421-0700|WARNING|sun-appserver-pe8.0.0_01|javax.enterprise.system.stream.err|_ThreadID=12;|java.sql.SQLException: Illegal operation on empty result set.
    at com.mysql.jdbc.ResultSet.checkRowPos(ResultSet.java:5327)
    at com.mysql.jdbc.ResultSet.getObject(ResultSet.java:1624)
    at com.sun.sql.rowset.JdbcRowSetXImpl.handleOnInsertRowGet(JdbcRowSetXImpl.java:2372)
    at com.sun.sql.rowset.JdbcRowSetXImpl.handleOnInsertRowGet(JdbcRowSetXImpl.java:2141)
    at com.sun.sql.rowset.JdbcRowSetXImpl.getObject(JdbcRowSetXImpl.java:1021)
    at com.sun.sql.rowset.JdbcRowSetXImpl.getObject(JdbcRowSetXImpl.java:1025)
    at com.sun.jsfcl.data.ResultSetPropertyResolver$ColumnData.getSelectItems(ResultSetPropertyResolver.java:303)
    at com.sun.jsfcl.data.ResultSetPropertyResolver.getValue(ResultSetPropertyResolver.java:61)
    at com.sun.faces.el.impl.ArraySuffix.evaluate(ArraySuffix.java:167)
    at com.sun.faces.el.impl.ComplexValue.evaluate(ComplexValue.java:151)
    at com.sun.faces.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:243)
    at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:173)
    at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:154)
    at javax.faces.component.UISelectItems.getValue(UISelectItems.java:110)
    at com.sun.faces.util.Util.getSelectItems(Util.java:600)
    at com.sun.faces.renderkit.html_basic.MenuRenderer.getOptionNumber(MenuRenderer.java:488)
    at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:465)
    at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:430)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:720)
    at javax.faces.webapp.UIComponentTag.encodeEnd(UIComponentTag.java:623)
    at javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:546)
    at com.sun.faces.taglib.html_basic.SelectOneListboxTag.doEndTag(SelectOneListboxTag.java:521)
    at org.apache.jsp.TasNewInventoryPage_jsp._jspx_meth_h_selectOneListbox_0(TasNewInventoryPage_jsp.java:425)
    at org.apache.jsp.TasNewInventoryPage_jsp._jspx_meth_h_form_0(TasNewInventoryPage_jsp.java:170)
    at org.apache.jsp.TasNewInventoryPage_jsp._jspx_meth_f_view_0(TasNewInventoryPage_jsp.java:122)
    at org.apache.jsp.TasNewInventoryPage_jsp._jspService(TasNewInventoryPage_jsp.java:83)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:102)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:861)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:282)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:263)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:210)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:861)
    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:324)
    at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:246)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
    at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:268)
    at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:162)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:236)
    at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
    at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:145)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:141)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:718)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:478)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:413)
    at org.apache.catalina.core.ApplicationDispatcher.access$000(ApplicationDispatcher.java:77)
    at org.apache.catalina.core.ApplicationDispatcher$PrivilegedForward.run(ApplicationDispatcher.java:92)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:319)
    at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
    at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
    at com.sun.jsfcl.app.ViewHandlerImpl.renderView(ViewHandlerImpl.java:169)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
    at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
    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:324)
    at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:246)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
    at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:268)
    at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:162)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:236)
    at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
    at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:145)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:141)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:109)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:522)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:214)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:168)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:109)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:522)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:144)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:109)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:133)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:539)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107)
    at com.sun.enterprise.webservice.EjbWebServiceValve.invoke(EjbWebServiceValve.java:134)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107)
    at com.sun.enterprise.security.web.SingleSignOn.invoke(SingleSignOn.java:254)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107)
    at com.sun.enterprise.web.VirtualServerValve.invoke(VirtualServerValve.java:209)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:522)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:114)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:109)
    at com.sun.enterprise.web.VirtualServerMappingValve.invoke(VirtualServerMappingValve.java:166)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.|#]
    [#|2005-02-14T17:46:33.421-0700|WARNING|sun-appserver-pe8.0.0_01|javax.enterprise.system.stream.err|_ThreadID=12;|java:107)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:522)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:936)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:165)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:683)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:604)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:542)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:647)
    at java.lang.Thread.run(Thread.java:534)
    |#]

  • Invalid Handle SQLException - HELP!!

    I am using a timer and a counter to automaticallyinsert records into my table at predefined intervals. The counter is used to provide the unique PersonID. My first record is inserted fine, where PersonID is 0. As soon as PersonID is 1 or more, I get an Invalid Handle SQLException.
    The line which is generating the error is:
    stmt.setInt(1, id);
    Relevent code is given below:
         * Insert a record into the Person table,
        private void insertPersonRecord(int id) {
            try {
                connection.setAutoCommit(false);
    System.err.println("ID: " + id);
                stmt.setInt(1, id);
                stmt.setString(2, "First_name");
                stmt.setString(3, "Sur_name");
                stmt.executeUpdate();
                connection.commit();
                connection.setAutoCommit(true);
                stmt.close();
    System.err.println("Person record inserted");
            catch(SQLException sqlex) {
    System.err.println("Unable to insert person record");
                sqlex.printStackTrace();
         * Set up timer actions.
        class InsertTask extends TimerTask {
            public void run() {
                insertPersonRecord(id);
                id++;
                if (id == 20) {
    System.err.println("Timer stopped - shutting down");                   
                    shutDown();
        }I just can't work this out. Any ideas?
    Cheers,
    Sandra.

    More code:
    * Simple JDBC prototype using the Sports.mdb MSAccess database.
    public class JDBCPrototype {
        private Connection connection;
        private PreparedStatement stmt;
        private Timer timer;
        private int id = 0;
        public JDBCPrototype() {
            // Connect to the Sports database using a JDBC-ODBC bridge.
            final String url = "jdbc:odbc:Sports";
            final String username = "JDBCPrototype";
            final String password = "test";
              // Load the driver to allow connection to the database          
            try {
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                connection = DriverManager.getConnection(url, username, password);
    System.err.println("Connection established");           
            catch (ClassNotFoundException cnfex) {
    System.err.println("Failed to load JDBC/ODBC driver.");
                cnfex.printStackTrace();
                System.exit(1);
            catch (SQLException sqlex) {
    System.err.println("Unable to connect");
                sqlex.printStackTrace();
            String insertString = "INSERT INTO PARTICIPANTS " +
                "VALUES (?, ?, ?)";
            try {
                stmt = connection.prepareStatement(insertString);    
            catch(SQLException sqlex) {
                sqlex.printStackTrace();
    System.err.println("Unable to prepare statement");           
            //empty database
            try {
                Statement statement = connection.createStatement();
                statement.executeUpdate
                        ("DELETE * FROM PARTICIPANTS");
    System.err.println("Table emptied");
            catch(SQLException sqlex) {
    System.err.println("Unable to empty table");
                sqlex.printStackTrace();
            startTimer();
         * Insert records using the timer.
        private void startTimer() {
              timer = new Timer();       
            final int DELAY = 50;
            timer.schedule(new InsertTask(), 0, DELAY);    
    System.err.println("Timer started");
        }   

  • Exception SQLException not handled

    Is this code above i get the SQLException in the catch statement and throws a new bussiness exception.
    The problem is that the SQLException looks like not handled, as it goes out the same SQLException, not the bussiness exception.
    Above goes the code and stacktrace :
    Connection con=null;
    Statement stmt=null;
    ResultSet rset=null;
    DirPart dirPart=null;
    String wClause =null;
    try
    wClause ="SELECT l.nom_localidade,to_char(co.dat_constituicao,'DD-MM-YY') dat_constituicao ,to_char(co.dat_ini_vigencia,'DD-MM-YY') dat_ini_vigencia ,to_char(co.dat_fim_vigencia,'DD-MM-YY') dat_fim_vigencia,co.num_protocolo,to_char(co.dat_protocolo,'DD-MM-YY') dat_protocolo,to_char(co.dat_prox_convencao,'DD-MM-YY') dat_prox_convencao ,o.cod_localidade_tse,co.cod_composicao,p.num_partido,p.nom_partido,p.sgl_partido,t.des_tipo_orgao,o.des_endereco,o.nom_bairro,o.num_cep,o.telefones,o.fax,o.email FROM ORGAO_PARTIDARIO O,MVW_PARTIDO p,COMPOSICAO_ORGAO CO, TIPO_ORGAO T,MVW_LOCALIDADE_UF l WHERE o.cod_localidade_tse=l.cod_localidade_tse and co.cod_composicao="+cod_composicao+" and p.num_partido=o.num_partido and co.cod_orgao=o.cod_orgao and co.tipo_orgao=t.tipo_orgao and co.ativa='S' order by p.sgl_partido";
    line 133 con=ConnManager.getConn("extcad");
    stmt = con.createStatement();
    rset = stmt.executeQuery(wClause.toString());
    if (rset.next())
    dirPart= new DirPart(rset.getString("des_tipo_orgao"),rset.getString("cod_composicao"),rset.getString("num_partido"),rset.getString("nom_partido"),rset.getString("sgl_partido"),rset.getString("cod_localidade_tse"),rset.getString("nom_localidade"),rset.getString("des_endereco"),rset.getString("nom_bairro"),rset.getString("num_cep"),rset.getString("telefones"),rset.getString("fax"),rset.getString("email"),rset.getString("dat_constituicao"),rset.getString("dat_ini_vigencia"),rset.getString("dat_fim_vigencia"),rset.getString("num_protocolo"),rset.getString("dat_protocolo"),rset.getString("dat_prox_convencao"));
    catch (SQLException e)
    e.printStackTrace();
    System.out.println("sql:"+wClause);
    throw new NaoCompletouOperacaoException("Erro de banco de dados");
    finally
    try
    con.close();
    rset.close();
    stmt.close();
    } catch (SQLException e) {System.err.println("erro ao fechar conn "+e.getMessage() );}
    return dirPart;
    STACK TRACE:
    java.sql.SQLException: ORA-00942: table or view does not exist
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:643)
    at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:1674)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1870)
    at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:538)
    at com.bitmechanic.sql.PooledStatement.executeQuery(PooledStatement.java:43)
    at justicaEleitoral.CPartDAO.getDirPartDoBD(CPartDAO.java:133)
    at justicaEleitoral.CPartDAO.getDirPart(CPartDAO.java:115)
    at partServlet.consultaPartido(partServlet.java:124)
    at partServlet.doGet(partServlet.java:53)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
    at org.apache.tomcat.core.Handler.service(Handler.java:287)
    at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
    at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:806)
    at org.apache.tomcat.core.ContextManager.service(ContextManager.java:752)

    That�s that method indeed. Here goes the entire method code :
    public static DirPart getDirPartDoBD(String cod_composicao) throws NaoCompletouOperacaoException
    Connection con=null;
    Statement stmt=null;
    ResultSet rset=null;
    DirPart dirPart=null;
    String wClause =null;
    try
    wClause ="SELECT l.nom_localidade,to_char(co.dat_constituicao,'DD-MM-YY') dat_constituicao ,to_char(co.dat_ini_vigencia,'DD-MM-YY') dat_ini_vigencia ,to_char(co.dat_fim_vigencia,'DD-MM-YY') dat_fim_vigencia,co.num_protocolo,to_char(co.dat_protocolo,'DD-MM-YY') dat_protocolo,to_char(co.dat_prox_convencao,'DD-MM-YY') dat_prox_convencao ,o.cod_localidade_tse,co.cod_composicao,p.num_partido,p.nom_partido,p.sgl_partido,t.des_tipo_orgao,o.des_endereco,o.nom_bairro,o.num_cep,o.telefones,o.fax,o.email FROM ORGAO_PARTIDARIO O,MVW_PARTIDO p,COMPOSICAO_ORGAO CO, TIPO_ORGAO T,MVW_LOCALIDADE_UF l WHERE o.cod_localidade_tse=l.cod_localidade_tse and co.cod_composicao="+cod_composicao+" and p.num_partido=o.num_partido and co.cod_orgao=o.cod_orgao and co.tipo_orgao=t.tipo_orgao and co.ativa='S' order by p.sgl_partido";
    con=ConnManager.getConn("extcad");
    // con=ConnCad.getConnExt();
    stmt = con.createStatement();
    rset = stmt.executeQuery(wClause.toString());
    if (rset.next())
    dirPart= new DirPart(rset.getString("des_tipo_orgao"),rset.getString("cod_composicao"),rset.getString("num_partido"),rset.getString("nom_partido"),rset.getString("sgl_partido"),rset.getString("cod_localidade_tse"),rset.getString("nom_localidade"),rset.getString("des_endereco"),rset.getString("nom_bairro"),rset.getString("num_cep"),rset.getString("telefones"),rset.getString("fax"),rset.getString("email"),rset.getString("dat_constituicao"),rset.getString("dat_ini_vigencia"),rset.getString("dat_fim_vigencia"),rset.getString("num_protocolo"),rset.getString("dat_protocolo"),rset.getString("dat_prox_convencao"));
    catch (SQLException e)
    e.printStackTrace();
    System.out.println("sql:"+wClause);
    throw new NaoCompletouOperacaoException("Erro de banco de dados");
    finally
    try
    con.close();
    rset.close();
    stmt.close();
    } catch (SQLException e) {System.err.println("erro ao fechar conn "+e.getMessage() );}
    return dirPart;

  • Invalid Handle SQL Exception

    Everytime I call this method from my JSP page, I get the error Invalid Handle. I changed my query statement at the most bottom part to a hard-coded update statement (this one update wirtech.orders_temp set BOOKCODE ='12345678', QUANTITY = '150', SUPPLIER = 'rain', STAT = 'pending', FULFILLED = '0', CONSOLIDATED = '1', CONSOLIDATEID ='1' where POID = '10003) but i still get that error. I traced my program and found out the error comes out at After System.out.println("hereba2"+query);. That's the line before stmt.executeupdate(query); at the bottom part of the consolidatePOS method.
    Please help, we've been stuck here for one week already.
         public void consolidatePOS(Vector v, String code)
              try{
                   String poidfinal = "";
                   int y = 0;
                   int qty = 0;
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   con = DriverManager.getConnection(url, username, password);
                stmt = con.createStatement();
                System.out.println("before big while."+v.size());
                   while(y<v.size())
                query = "select QUANTITY from wirtech.orders_temp where POID = '"+v.elementAt(y)+"'";
                System.out.println("first stmt.execute");
                rs=stmt.executeQuery(query);
                System.out.println("inside medium while.");
                while (rs.next())
                     System.out.println("inside small while.");
                     qty = qty + rs.getInt("QUANTITY");
                if(y == v.size()-1)
                     poidfinal = ""+v.elementAt(y);
                y++;
                rs.close();
                System.out.println("after big while.");
                int ea = getConsolidateID();
                System.out.println("ea"+ea);
                System.out.println("here ba/!?");
                query = "update wirtech.orders_temp set BOOKCODE ='12345678', QUANTITY = '150', SUPPLIER = 'rain', STAT = 'pending', FULFILLED = '0', CONSOLIDATED = '1', CONSOLIDATEID ='1' where POID = '10003'";
                System.out.println("here ba2"+query);
                stmt.executeUpdate(query);
                System.out.println("after big while. LASTT");
                stmt.close(); con.close();
                } catch(Exception ex) {
                     System.out.println("error in consolidatePOS()" + ex);     
              public int getConsolidateID()
              {int x =0;
                   try {
                Class.forName(driver);
                con = DriverManager.getConnection(url, username, password);
                stmt = con.createStatement();
                query = "SELECT COUNT(DISTINCT CONSOLIDATEID) AS count FROM wirtech.orders_temp";
                rs = stmt.executeQuery(query);
                while (rs.next()) {
                    x = rs.getInt("count");
                rs.close();
                stmt.close();
                con.close();
            } catch (Exception e) {
                System.out.println("getTransactionCount has an Exception: " + e);
            }

    This is a complete guess! ... perhaps the
    rs.close();also closes the Statement (or invalidates it) which you use later to execute the update. The API does not seem to indicate this though:
    void close()
               throws SQLException
        Releases this ResultSet object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed.
        Note: A ResultSet object is automatically closed by the Statement object that generated it when that Statement object is closed, re-executed, or is used to retrieve the next result from a sequence of multiple results. A ResultSet object is also automatically closed when it is garbage collected. But perhaps it may still be worthwhile seeing if removing that close will fix the problem.

  • Invalid Handle Exception-What is the reason?

    I face with "Invalid Handle exception" (SQLException) while using the following code.
    Could anybody tell me the possible reasons/Situation the error rise?
    stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery(SQLStmt);
         if(rs!=null){
    ResultSetMetaData rsm = rs.getMetaData();
         int totalcols = rsm.getColumnCount();
         Vector temp;
         while (rs.next()) {
         Vector temp = new Vector();
         for (int i = 1; i <= totalcols; i++) {
              String value = rs.getString(i);
              if (value == null) {
              value = "";
         temp.addElement(value);
         }//for loop ends here
         valueVector.addElement(temp);
         rs.close();
         stmt.close();     
    Thank you all

    Vector temp;
    while (rs.next()) {
    Vector temp = new Vector();Are you sure that this is the code you are running? The reason I ask is that I'm pretty sure that it won't compile, at least under JDK1.4. You should get a compile error something like "temp is already defined".
    If thats not the problem you need to find out on which line the error actually occurs. You can get this from the exception by calling the printStackTrace() method.
    Col

  • SQL Exception - Invalid Handle

    I am writing a program for a order company using java beans. I have everything working except when i try to add a new item into the database it throws a exception saying: invlaid handle. The code for that bean file is given below..any help will be really appreciated. The error is under setNewItem function on code: results = statement.executeQuery(select).
    package stockBeans;
    import java.sql.*;
    public class StockAccess
         private Connection connection;
         private Statement statement;
         private ResultSet results;
         public StockAccess() throws ClassNotFoundException
              try
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              catch (ClassNotFoundException cnfEx)
                   throw new ClassNotFoundException(
                                  "Unable to locate JDBC driver!");
         public String getStockLevel(String code) throws SQLException
              int stockLevel;
              String returnValue="";
              boolean match=false;
              connectAndCreateStatement();
              results = statement.executeQuery("SELECT * FROM StockItems");          
              while((results.next())&&(match==false))
                   if(code.equalsIgnoreCase(results.getString(1)))
                        match=true;
                        stockLevel = results.getInt(3);
                        returnValue = Integer.toString(stockLevel);
              if(!match)
                   returnValue="error";
              disconnectFromDb();
              return returnValue;
         public void setNewItem(String code, String desc, int currentLvl,int reorderLvl,Float price)
                                       throws SQLException
              boolean found;
              connectAndCreateStatement();
              found = findMatch(code);
              if(found==false)
                   try
                        String select = "SELECT * FROM StockItems";
                        **results = statement.executeQuery(select);**
                        String insert = "INSERT INTO StockItems VALUES (" + "'" + code
                                            + "'" + "," + "'" + desc + "'" + "," +
                                            + currentLvl + "," reorderLvl "," price ")";
                        int result = statement.executeUpdate(insert);
                        System.out.print("Congratulation. Match Data Saved");
                   catch(SQLException sqlEx)
                        System.out.println("* Error Inserting Data! *" + sqlEx);
              else
                   System.out.println("\n Code Already Entered. Try Again \n");
         public void getStock()
                        throws SQLException
              connectAndCreateStatement();
              System.out.println();
              System.out.println("Code"+"\t\t"+" Description"
                        +"\t"+"Current Level"+"\t"+"Reorder Level"+"\t"+"Cost");
              results = statement.executeQuery("SELECT * FROM StockItems");
              while (results.next())
                   System.out.println(results.getString(1)
                                            +"\t\t"+results.getString(2)
                                            +"\t\t"+results.getInt(3)
                                            +"\t\t"+ results.getInt(4)
                                            +"\t\t"+results.getFloat(5));
         public boolean findMatch(String code)
                                       throws SQLException
              boolean found=false;
              connectAndCreateStatement();
              try
                   results = statement.executeQuery("SELECT * FROM StockItems");          
                   while(results.next()&& (found==false))
                        if(code.equalsIgnoreCase(results.getString(1)))
                             found=true;
                        else
                             found=false;
              catch(SQLException sqlEx)
                   System.out.println("Unable to retrieve data");
              disconnectFromDb();
              return found;     
         private void connectAndCreateStatement() throws SQLException
              try
                   connection = DriverManager.getConnection(
                                                 "jdbc:odbc:StockData","","");
                   //*** Change DSN name if yours is different! ***
              catch (SQLException sqlEx)
                   throw new SQLException("Unable to connect to database!");
              try
                   statement = connection.createStatement();
              catch (SQLException sqlEx)
                   throw new SQLException("Unable to create SQL statement!");
         private void disconnectFromDb() throws SQLException
              try
                   connection.close();
              catch (SQLException sqlEx)
                   throw new SQLException(
                             "Unable to disconnect from database!");
    }

    I have found the problem..i am closing the DB in findMatch function.
    Thank You.

Maybe you are looking for

  • Hooking up Airport Express for the first time

    Hi - Like many others, I just can't seem to figure out how to hook up my AirPort Express (802.11n). Here is how I am currently set up ... In the basement I have a Mac Mini hooked up to an ActionTec GT701-WG wireless router (from Qwest), but I am usua

  • Using applet to select a part of an image and then save it

    Hi , I want to use applet to select a part of an image and then save that particular selected part to a server. can anyone provide me a code for this. I have found codes on the sun site which help in uploading an image but I am having trouble in tryi

  • Messages stuck in QRFC inbound and outbound queues by system error

    Hi Experts, We faced a big problem in our PI server which stopped all the traffic in the iDoc to File interface. Both the QRFC queues (inbound - SMQ1 as outbound - SMQ2) where stuck by a system error. In IDX5 of PI we saw two inbound iDocs on exact t

  • Podcasts Gone

    Since the itunes upgrade I lost my podcasts, can't seem to get them back, any ideas?

  • How can I format my usb install drive?

    how can I format mymacbook air software install drive.?, the ones that came with the Macbook Air as the OS is now old I have no Use for the Drive and would like to use it as a stylish usb flash drive. the one I mean is here Is it actually possible to