Subqueries in a PreparedStatement

Hi,
I am using a subquery in a prepared statement as follows
INSERT INTO CTL_ALERT_EXCEPTION(ALERT_EXCEPTION_ID, MPAN, ALERT_TYPE, DATE_TIME_RAISED, STATUS, SUPPLIER_ID, ALERT_ID1) VALUES (ALERTEXCEPTIONID_SEQ.NEXTVAL, ?, ?, SYSDATE, 'OPEN', ?, (SELECT ALERT_ID FROM ALERT WHERE ALERT_TYPE = ?))
with the above query I am getting the following error
java.sql.SQLException: ORA-01400: cannot insert NULL into ("RND"."CTL_ALERT_EXCEPTION"."ALERT_ID1")
but if I hardcode the value in the subquery the prepared statement is working fine but not for dynamic substitution.
I am using Oracle 10g (10.1.0.4) thin driver (ojdbc14.jar ).
Can anybody give me the solution.
Thanks & Regards
Senthil

Senthil,
I can reproduce your error using "ojdbc14.jar" [JDBC] driver. I suggest you check the MetaLink Web site to see whether this is a known issue. And if it is not, then you can create a "technical assistance request" (TAR) for it.
Good Luck,
Avi.

Similar Messages

  • Database search not working

    Hi all,
    I am new to Orcale SES. I have to search database using SES. I have created database source with the following details:
    Database Connection String,User ID,Password,View,Document Count,URL Prefix, Parse Attributes,
    Remove deleted documents,Attachment Link Authentication Type
    When I schedule crawler on database, log file shows following:
    06:26:34:773 INFO     main          Total number of documents fetched = 0
    06:26:34:773 INFO     main          Document fetch failures = 0
    06:26:34:773 INFO     main          Document conversion failures = 0
    06:26:34:774 INFO     main          Total number of unique documents indexed = 0
    06:26:34:774 INFO     main          Total data collected = 0 bytes
    06:26:34:774 INFO     main          Total number of non-indexable documents = 0
    06:26:34:774 INFO     main          
    06:26:34:774 INFO     main          Number of times disk cache is full = 0
    crawl statistics is 0.
    Am I missing something here?
    Please help.
    Regards,
    Purnima

    Hi,
    I have given table name (TESTSES) in view parameter. Yes TESTSES table contains all the mandatory parameters.
    Crawler log file is not showing any errors. Following are the log file details:
    06:26:10:518 INFO     main          Loading training data /u01/apps/oracle/product/11.1.2.0.0/ses/seshome/search/data/training//german.dat for language de
    06:26:10:528 INFO     main          Loading training data /u01/apps/oracle/product/11.1.2.0.0/ses/seshome/search/data/training//italian.dat for language it
    06:26:10:540 INFO     main          Loading training data /u01/apps/oracle/product/11.1.2.0.0/ses/seshome/search/data/training//portugue.dat for language pt
    06:26:10:551 INFO     main          Loading training data /u01/apps/oracle/product/11.1.2.0.0/ses/seshome/search/data/training//spanish.dat for language es
    06:26:10:570 INFO     main          Done
    06:26:11:636 INFO     filter_0          Initializing crawler plug-in "Database Crawler Plugin"
    06:26:11:636 INFO     crawler_4          Initializing crawler plug-in "Database Crawler Plugin"
    06:26:11:637 INFO     crawler_4          AppJDBC crawler initialization: Connection string is jdbc:oracle:thin:@nacisdell221.us.oracle.com:1534:BFNDEV
    06:26:11:636 INFO     crawler_3          Initializing crawler plug-in "Database Crawler Plugin"
    06:26:11:636 INFO     filter_0          AppJDBC crawler initialization: Connection string is jdbc:oracle:thin:@nacisdell221.us.oracle.com:1534:BFNDEV
    06:26:11:637 INFO     crawler_2          Initializing crawler plug-in "Database Crawler Plugin"
    06:26:11:637 INFO     crawler_2          AppJDBC crawler initialization: Connection string is jdbc:oracle:thin:@nacisdell221.us.oracle.com:1534:BFNDEV
    06:26:11:637 INFO     crawler_3          AppJDBC crawler initialization: Connection string is jdbc:oracle:thin:@nacisdell221.us.oracle.com:1534:BFNDEV
    06:26:11:636 INFO     filter_1          Initializing crawler plug-in "Database Crawler Plugin"
    06:26:11:638 INFO     filter_1          AppJDBC crawler initialization: Connection string is jdbc:oracle:thin:@nacisdell221.us.oracle.com:1534:BFNDEV
    06:26:11:649 INFO     crawler_4          Loading oracle Driver
    06:26:11:649 INFO     crawler_4          Connecting to database jdbc:oracle:thin:@nacisdell221.us.oracle.com:1534:BFNDEV, user: arg
    06:26:11:650 INFO     filter_0          Loading oracle Driver
    06:26:11:651 INFO     filter_0          Connecting to database jdbc:oracle:thin:@nacisdell221.us.oracle.com:1534:BFNDEV, user: arg
    06:26:11:653 INFO     crawler_2          Loading oracle Driver
    06:26:11:653 INFO     crawler_2          Connecting to database jdbc:oracle:thin:@nacisdell221.us.oracle.com:1534:BFNDEV, user: arg
    06:26:11:658 INFO     crawler_3          Loading oracle Driver
    06:26:11:658 INFO     crawler_3          Connecting to database jdbc:oracle:thin:@nacisdell221.us.oracle.com:1534:BFNDEV, user: arg
    06:26:11:668 INFO     filter_1          Loading oracle Driver
    06:26:11:668 INFO     filter_1          Connecting to database jdbc:oracle:thin:@nacisdell221.us.oracle.com:1534:BFNDEV, user: arg
    06:26:15:328 INFO     crawler_4          Crawler plug-in "Database Crawler Plugin" crawl starts
    06:26:15:331 INFO     crawler_4          Previous max. last modified date: 2010-05-24T00:00:00
    06:26:15:331 INFO     crawler_4          Query key only= false; SQL Statement = select * from (select * from (TESTSES) mqry where LASTMODIFIEDDATE > ?) where ROLLNO = ?
    06:26:15:331 INFO     crawler_4          No subqueries to create PreparedStatements
    06:26:15:331 INFO     crawler_4          No subqueries to create PreparedStatements
    06:26:18:332 INFO     filter_1          Crawler plug-in "Database Crawler Plugin" crawl starts
    06:26:18:334 INFO     filter_1          Previous max. last modified date: 2010-05-24T00:00:00
    06:26:18:334 INFO     filter_1          Query key only= false; SQL Statement = select * from (select * from (TESTSES) mqry where LASTMODIFIEDDATE > ?) where ROLLNO = ?
    06:26:18:334 INFO     filter_1          No subqueries to create PreparedStatements
    06:26:18:334 INFO     filter_1          No subqueries to create PreparedStatements
    06:26:21:366 INFO     crawler_3          Crawler plug-in "Database Crawler Plugin" crawl starts
    06:26:21:367 INFO     crawler_3          Previous max. last modified date: 2010-05-24T00:00:00
    06:26:21:368 INFO     crawler_3          Query key only= false; SQL Statement = select * from (select * from (TESTSES) mqry where LASTMODIFIEDDATE > ?) where ROLLNO = ?
    06:26:21:368 INFO     crawler_3          No subqueries to create PreparedStatements
    06:26:21:368 INFO     crawler_3          No subqueries to create PreparedStatements
    06:26:24:367 INFO     crawler_2          Crawler plug-in "Database Crawler Plugin" crawl starts
    06:26:24:368 INFO     crawler_2          Previous max. last modified date: 2010-05-24T00:00:00
    06:26:24:368 INFO     crawler_2          Query key only= false; SQL Statement = select * from (select * from (TESTSES) mqry where LASTMODIFIEDDATE > ?) where ROLLNO = ?
    06:26:24:368 INFO     crawler_2          No subqueries to create PreparedStatements
    06:26:24:368 INFO     crawler_2          No subqueries to create PreparedStatements
    06:26:27:415 INFO     filter_0          Crawler plug-in "Database Crawler Plugin" crawl starts
    06:26:27:416 INFO     filter_0          Previous max. last modified date: 2010-05-24T00:00:00
    06:26:27:416 INFO     filter_0          Query key only= true; SQL Statement = select URL,ROLLNO,LANG,LASTMODIFIEDDATE from (select * from (TESTSES) mqry where LASTMODIFIEDDATE > ?)
    06:26:27:686 INFO     filter_0          Master query execution time: 270ms
    06:26:27:686 INFO     filter_0          Previous max. last modified date: 2010-05-24T00:00:00
    06:26:27:687 INFO     filter_0          Query key only= false; SQL Statement = select * from (select * from (TESTSES) mqry where LASTMODIFIEDDATE > ?) where ROLLNO = ?
    06:26:27:687 INFO     filter_0          No subqueries to create PreparedStatements
    06:26:27:687 INFO     filter_0          No subqueries to create PreparedStatements
    06:26:27:687 INFO     filter_0          Shut down crawler plug-in "Database Crawler Plugin"
    06:26:27:956 INFO     filter_0          Shut down crawler plug-in "Database Crawler Plugin"
    06:26:28:227 INFO     filter_0          Shut down crawler plug-in "Database Crawler Plugin"
    06:26:28:497 INFO     filter_0          Shut down crawler plug-in "Database Crawler Plugin"
    06:26:28:768 INFO     filter_0          Shut down crawler plug-in "Database Crawler Plugin"
    06:26:29:038 INFO     filter_0          Shutting down all crawling threads...
    06:26:29:038 INFO     filter_0          Crawler plug-in "Database Crawler Plugin" crawl finishes
    06:26:29:039 INFO     filter_0          Shut down document service agent "Default pipeline"
    06:26:29:039 INFO     crawler_4          Crawler plug-in "Database Crawler Plugin" crawl finishes
    06:26:29:040 INFO     filter_1          Crawler plug-in "Database Crawler Plugin" crawl finishes
    06:26:29:041 INFO     crawler_2          Crawler plug-in "Database Crawler Plugin" crawl finishes
    06:26:29:041 INFO     crawler_3          Crawler plug-in "Database Crawler Plugin" crawl finishes
    06:26:29:061 INFO     cache_0          Caching thread cache_0 returns without getting a file
    06:26:29:062 INFO     cache_0          Shutting down all caching threads...
    06:26:29:062 INFO     cache_1          Caching thread cache_1 returns without getting a file
    06:26:29:062 INFO     cache_2          Caching thread cache_2 returns without getting a file
    06:26:29:062 INFO     cache_0          Total number of documents cached = 0
    06:26:29:062 INFO     cache_0          Total data collected = 0 bytes
    06:26:29:062 INFO     cache_0          Indexing log file is "search_i1ds4.log" under oracle_home/ctx/log/
    06:26:29:098 INFO     cache_0          Indexing started at 5/24/10 6:26 AM
    06:26:29:098 INFO     cache_0          Task ID = 19
    06:26:29:234 INFO     monitor          Remote command "reportstatistics" received, argument = "null"
    06:26:29:262 INFO     monitor          Executing remote command "reportstatistics"
    06:26:29:266 INFO     monitor          Send back remote command execution result
    06:26:29:515 INFO     cache_0          Indexing completed at 5/24/10 6:26 AM
    06:26:34:518 INFO     cache_0          Done
    06:26:34:518 INFO     main          Shutting down crawler...
    06:26:34:518 INFO     main          Shut down crawler plug-in "oracle.search.plugin.db.DBCrawlerManager"
    06:26:34:718 INFO     monitor          Remote command "reportstatistics" received, argument = "quit"
    06:26:34:718 INFO     monitor          Executing remote command "reportstatistics"
    06:26:34:719 INFO     monitor          Send back remote command execution result
    06:26:34:772 INFO     main          Done
    06:26:34:772 INFO     main          
    06:26:34:772 INFO     main          =================== Crawling results ===================
    06:26:34:773 INFO     main          Crawling started at 5/24/10 6:26 AM
    06:26:34:773 INFO     main          Crawling stopped at 5/24/10 6:26 AM
    06:26:34:773 INFO     main          Total crawling time = 0:0:28
    06:26:34:773 INFO     main          
    06:26:34:773 INFO     main          Total number of documents fetched = 0
    06:26:34:773 INFO     main          Document fetch failures = 0
    06:26:34:773 INFO     main          Document conversion failures = 0
    06:26:34:774 INFO     main          Total number of unique documents indexed = 0
    06:26:34:774 INFO     main          Total data collected = 0 bytes
    06:26:34:774 INFO     main          Total number of non-indexable documents = 0
    06:26:34:774 INFO     main          
    06:26:34:774 INFO     main          Number of times disk cache is full = 0

  • Nothing can be crawled from DB... WHY?

    Hello.
    I set up a database source with a table in it. However, after being crawler, no data had been crawled according to log.
    Can anyone help me where I am wrong? How to configure?
    LOG:
    21:04:30:999 INFO     filter_0          Crawling text attachments for http://1
    21:04:30:999 FATAL     filter_0          EQP-80407: Exception while processing document: EQP-80430: Cache file /tmp/cachefile-1 could not be created. Aborting...
    21:04:30:999 FATAL     filter_0     EQP-80430: Cache file /tmp/cachefile-1 could not be created. Aborting... oracle.search.sdk.crawler.PluginException     oracle.search.plugin.appsjdbc.AppsJdbcPlugin:processDocuments:972     oracle.search.plugin.appsjdbc.AppsJdbcPlugin:crawl:1150     oracle.search.crawler.CrawlingThread:run:1490
    21:04:30:999 INFO     filter_0          Dequeued http://2
    21:04:30:999 INFO     filter_0          Could not find previous lastmodified date. Assuming that doc has changed..
    21:04:30:999 INFO     filter_0          Content type not available. Setting to default content type: text/plain
    21:04:30:999 INFO     filter_0          No attribute queries to process for http://2
    21:04:30:999 INFO     filter_0          No attachment queries to process for http://2
    21:04:30:999 INFO     filter_0          Crawling text attachments for http://2
    21:04:30:999 FATAL     filter_0          EQP-80407: Exception while processing document: EQP-80430: Cache file /tmp/cachefile-1 could not be created. Aborting...
    21:04:30:999 FATAL     filter_0     EQP-80430: Cache file /tmp/cachefile-1 could not be created. Aborting... oracle.search.sdk.crawler.PluginException     oracle.search.plugin.appsjdbc.AppsJdbcPlugin:processDocuments:972     oracle.search.plugin.appsjdbc.AppsJdbcPlugin:crawl:1150     oracle.search.crawler.CrawlingThread:run:1490
    21:04:30:999 INFO     filter_0          Shut down crawler plug-in "filter_0"
    21:04:31:015 INFO     filter_0          Shutting down all crawling threads...
    21:04:31:015 INFO     filter_0          Crawler plug-in "filter_0" crawl finishes
    21:04:31:015 INFO     filter_0          Shut down document service agent "Default pipeline"
    21:04:31:015 INFO     cache_0          Caching thread cache_0 returns without getting a file
    21:04:31:015 INFO     cache_0          Shutting down all caching threads...
    21:04:31:015 INFO     cache_1          Caching thread cache_1 returns without getting a file
    21:04:31:015 INFO     cache_2          Caching thread cache_2 returns without getting a file
    21:04:31:015 INFO     cache_0          Total number of documents cached = 0
    21:04:31:015 INFO     cache_0          Total data collected = 0 bytes
    21:04:31:015 INFO     cache_0          Indexing started at 9/20/09 9:04 PM
    21:04:31:015 INFO     cache_0          Task ID = 46
    21:04:31:077 INFO     Thread-1          Remote command "reportstatistics" received, argument = "null"
    21:04:31:077 INFO     Thread-1          Executing remote command "reportstatistics"
    21:04:31:077 INFO     Thread-1          Send back remote command execution result
    21:04:31:577 INFO     cache_0          Indexing completed at 9/20/09 9:04 PM
    21:04:36:577 INFO     cache_0          Done
    21:04:36:577 INFO     main          Shutting down crawler...
    21:04:36:577 INFO     main          Shut down crawler plug-in "oracle.search.plugin.db.DBCrawlerManager"
    21:04:36:577 INFO     main          Crawl Cleanup: Deleting all rows not seen in this crawl..
    21:04:36:858 INFO     Thread-1          Remote command "reportstatistics" received, argument = "quit"
    21:04:36:858 INFO     Thread-1          Executing remote command "reportstatistics"
    21:04:36:874 INFO     Thread-1          Send back remote command execution result
    21:04:36:999 INFO     main          Done
    21:04:36:999 INFO     main          
    21:04:36:999 INFO     main          =================== Crawling results ===================
    21:04:36:999 INFO     main          Crawling started at 9/20/09 9:04 PM
    21:04:36:999 INFO     main          Crawling stopped at 9/20/09 9:04 PM
    21:04:36:999 INFO     main          Total crawling time = 0:0:10
    21:04:36:999 INFO     main          
    21:04:36:999 INFO     main          Total number of documents fetched = 0
    21:04:36:999 INFO     main          Document fetch failures = 0
    21:04:36:999 INFO     main          Document conversion failures = 0
    21:04:36:999 INFO     main          Total number of unique documents indexed = 0
    21:04:36:999 INFO     main          Total data collected = 0 bytes
    21:04:36:999 INFO     main          Total number of non-indexable documents = 0
    21:04:36:999 INFO     main          
    21:04:36:999 INFO     main          Number of times disk cache is full = 0

    Now the date error is resolved but no results are displayed on search.
    23:11:46:894 INFO     filter_0          Query key only= false; SQL Statement = select * from ( select DEFAULT_URL URL,EO_PE_FULL_NAME CONTENT, AIAX_KEY KEY, EOIU_LANG_CD LANG , LAST_MOD_DT LASTMODIFIEDDATE FROM PS_AIAX_FINAL_VIEW ) inline_view where "KEY" = ?
    23:11:46:894 INFO     filter_0          No subqueries to create PreparedStatements
    23:11:46:894 INFO     filter_0          No subqueries to create PreparedStatements
    23:11:46:894 INFO     filter_0          Shut down crawler plug-in "filter_0"
    23:11:46:894 INFO     filter_0          Shut down crawler plug-in "filter_1"
    23:11:46:909 INFO     filter_0          Shut down crawler plug-in "crawler_2"
    23:11:46:909 INFO     filter_0          Shut down crawler plug-in "crawler_3"
    23:11:46:909 INFO     filter_0          Shut down crawler plug-in "crawler_4"
    23:11:46:909 INFO     filter_0          Shutting down all crawling threads...
    23:11:46:909 INFO     filter_0          Crawler plug-in "filter_0" crawl finishes
    23:11:46:909 INFO     crawler_2          Crawler plug-in "crawler_2" crawl finishes
    23:11:46:925 INFO     filter_0          Shut down document service agent "Default pipeline"
    23:11:46:925 INFO     filter_1          Crawler plug-in "filter_1" crawl finishes
    23:11:46:925 INFO     crawler_3          Crawler plug-in "crawler_3" crawl finishes
    23:11:46:925 INFO     crawler_4          Crawler plug-in "crawler_4" crawl finishes
    23:11:46:941 INFO     cache_0          Caching thread cache_0 returns without getting a file
    23:11:46:941 INFO     cache_0          Shutting down all caching threads...
    23:11:46:941 INFO     cache_1          Caching thread cache_1 returns without getting a file
    23:11:46:941 INFO     cache_2          Caching thread cache_2 returns without getting a file
    23:11:46:941 INFO     cache_0          Total number of documents cached = 0
    23:11:46:941 INFO     cache_0          Total data collected = 0 bytes
    23:11:46:941 INFO     cache_0          Indexing started at 10/12/09 11:11 PM
    23:11:46:941 INFO     cache_0          Task ID = 144
    23:11:47:066 INFO     Thread-1          Remote command "reportstatistics" received, argument = "null"
    23:11:47:066 INFO     Thread-1          Executing remote command "reportstatistics"
    23:11:47:066 INFO     Thread-1          Send back remote command execution result
    23:11:47:081 INFO     cache_0          Indexing completed at 10/12/09 11:11 PM
    23:11:52:080 INFO     cache_0          Done
    23:11:52:080 INFO     main          Shutting down crawler...
    23:11:52:080 INFO     main          Shut down crawler plug-in "oracle.search.plugin.db.DBCrawlerManager"
    23:11:52:080 INFO     main          Crawl Cleanup: Deleting all rows not seen in this crawl..
    23:11:52:361 INFO     Thread-1          Remote command "reportstatistics" received, argument = "quit"
    23:11:52:361 INFO     Thread-1          Executing remote command "reportstatistics"
    23:11:52:361 INFO     Thread-1          Send back remote command execution result
    23:11:52:486 INFO     main          Done
    23:11:52:486 INFO     main          
    23:11:52:486 INFO     main          =================== Crawling results ===================
    23:11:52:486 INFO     main          Crawling started at 10/12/09 11:11 PM
    23:11:52:486 INFO     main          Crawling stopped at 10/12/09 11:11 PM
    23:11:52:486 INFO     main          Total crawling time = 0:0:12
    23:11:52:486 INFO     main          
    23:11:52:486 INFO     main          Total number of documents fetched = 0
    23:11:52:486 INFO     main          Document fetch failures = 0
    23:11:52:486 INFO     main          Document conversion failures = 0
    23:11:52:486 INFO     main          Total number of unique documents indexed = 0
    23:11:52:486 INFO     main          Total data collected = 0 bytes
    23:11:52:486 INFO     main          Total number of non-indexable documents = 0
    23:11:52:486 INFO     main          
    23:11:52:486 INFO     main          Number of times disk cache is full = 0
    Edited by: user778360 on Oct 12, 2009 11:20 PM

  • How to print Integrity sql in the preparedstatement?

    How to print Integrity sql in the preparedstatement?
    Connection conn = null;
    String sql = "select * from person where name=?";
    PreparedStatement ps = conn.prepareStatement(sql);
    ps.setObject(1, "robin");
    ps.executeQuery();
    i'm wants print Integrity sql.
    For example:select * from person where name='robin'
    How should I do?
    thanks a lot!

    PreparedStatement doesn't offer methods for that. You can write your own implementation of PreparedStatement which wraps the originating PreparedStatement and saves the set* values and writes it to the toString().
    If needed, myself I just print the sql as well as the values-being-set to the debug statement.Logger.debug(query + " " + values);

  • PreparedStatement not working

    Hi,
    I am having some problem using PreparedStatement.executeUpdate() . I want to be able to prepare several queries before commiting and I wrote this just to test it
    PreparedStatement stmt= aConnection.prepareStatement("update trans_test1 set field1='a text field' where field1='other text'");
              stmt.executeUpdate();
              aConnection.commit();
              stmt.close();
              aConnection.close();
    when it hits this line "stmt.executeUpdate();" the program just stops running and after a while throws this error.
    java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
    I set the auto commit to false but I still can't get it working and do not understand the problem. Any one can help?
    Thanks so much
    Alejo

    Hi,
    I am having some problem using
    PreparedStatement.executeUpdate() . I want to be able
    to prepare several queries before commiting and I
    wrote this just to test it
    PreparedStatement stmt=
    aConnection.prepareStatement("update trans_test1 set
    field1='a text field' where field1='other text'");
              stmt.executeUpdate();This is wrong in so many ways:
    (1) Use the bind variables.
    (2) Close resources properly in a finally block.
    (3) You don't show where you set auto commit to false
    (4) You don't show where you rollback in the event of a failure.
    >
    I set the auto commit to false but I still can't get
    it working and do not understand the problem. Any one
    can help?A snippet like this isn't enough. Post all the code.
    Which database are you using, and which driver?
    %

  • Oracle, SELECT IN and PreparedStatement.setArray

    I want to execute the following query: SELECT * FROM SOMETABLE WHERE IDFIELD IN (?)
    The number of values in the IN list is variable. How can I do this with a prepared statement?
    I am aware of the different alternatives:
    1) Keep a cache of prepared statement for each sized list seen so far.
    2) Keep a cache of prepared statements for different sizes (1, 5, 10, 20) and fill in the left over parameter positions with the copies first value.
    They both have the disadvantage that there could be many prepared statements for each query that get used once, and never used again.
    I have tried this:
    stmt.execute ("CREATE OR REPLACE TYPE LONGINTLIST AS TABLE OF NUMBER(15)");
    ArrayDescriptor desc = ArrayDescriptor.createDescriptor ("LONGINTLIST", conn);
    long idValues [] = {2, 3, 4};
    oracle.sql.ARRAY paramArray = new oracle.sql.ARRAY (desc, conn, idValues);
    PreparedStatement query = conn.prepareStatement ("SELECT * FROM MYTABLE WHERE ID_FIELD IN (?)");
    query.setArray (1, paramArray);
    But Oracle gives a data conversion error.
    I then tried this:
    PreparedStatement query = conn.prepareStatement ("SELECT * FROM MYTABLE WHERE ID_FIELD IN (SELECT * FROM TABLE (?))");
    This works and the rows are returned, but the Oracle optimizer does not like it very much, since it always does a full table scan even though there is a primary key index on ID_FIELD.
    Any ideas?
    I also tried this:
    OraclePreparedStatement oraQuery = (OraclePreparedStatement) query;
    oraQuery.setARRAY (1, paramArray);
    But same behavior.
    Roger Hernandez

    Please re-read the original message. As I mentioned,
    I am aware of the two commonly used alternatives.No actually the most used alternative is to build the SQL dynamically each time.
    I know how to get both of them to work, and have used
    both alternatives in the past. The downside to both
    these approaches is that you need to save multiple
    prepared statements for each query. What I am trying
    to find is a way of having only one saved prepared
    statement for a query having a variable number of IN
    clause parameters.You could probably use a stored procedure that takes an 'array' and then do the processing in the stored proc to handle each array element.
    However, your database might not support that stored procs or arrays. Or it might not cache it with arrays. And the overhead of creating the array structure or processing it in the proc might eat any savings that you might gain (even presuming there is any savings) by using a prepared statement in the first place. Of course given that you must be using an automated profiling tool and have a loaded test environment you should be able to easily determine if this method saves time or not.
    Other than that there are no other solutions.

  • Problem with PreparedStatement

    I'm using a statement which needs to determine if the value is in a group.
    The statement will be
    "select name,age,occupation from personnel where age in ?"
    ps.setString(1, "(20,21,22)");
    I've also tried
    ps.setString(1, "('20','21','22')");
    Neither brings back any values in the result set.
    I can't figure out how to print what the preparedstatement looks like after setting the value.
    I look in the table and there are records with age 20, 21, 22.. and age is set as a string.

    Try this:
        query_B = "select tablename.blah_blah_blah"
                + "  from tablename"
                + " where tablename.etc is null"
                + "   and table.blah_term_code       in (?, ?)"
                + " order by 1, 2, 4, 7";
          String[] in_sem_dt = { "200307", "200308" };
          pstmt_B = con.prepareStatement( query_B );
          pstmt_B.setString( 1, in_sem_dt[0] );
          pstmt_B.setString( 2, in_sem_dt[1] );
          rs_B = pstmt_B.executeQuery();~Bill

  • Closing PreparedStatements & ResultSets

    Is it necessary to explicitly close ResultSet AND PreparedStatement objects when used together? For example:
    PreparedStatement ps;
    ResultSet rs;
    String sql = " SELECT * FROM some_table WHERE id = ? ";
    try {
        ps = connection.prepareStatement(sql);
        ps.setString(1, someId);
        rs = ps.executeQuery();
        // And so on.....
    } finally {
      rs.close();
      ps.close();
    }Is it sufficient to close only the PreparedStatement? Does the ResultSet get cleaned up automatically when the PreparedStatement is closed? I don't want any lingering cursors left open, but at the same time, I don't want to write code that isn't needed. What's considered best form?
    Thanks.
    BTW: I'm using Oracle 8i/9i.

    I always close a Statement object, but don't worry about the ResultSet...that's really just a matter of redundancy...
    From the API on Statement.close()
    Note: A Statement object is automatically closed when it is garbage collected. When a Statement object is closed, its current ResultSet object, if one exists, is also closed.

  • Too many connections - even after closing ResultSets and PreparedStatements

    I'm getting a "Too many connections" error with MySQL when I run my Java program.
    2007-08-06 15:07:26,650 main/CLIRuntime [FATAL]: Too many connections
    com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Too many connections
            at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:921)
            at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
            at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:812)
            at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3269)
            at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1182)
            at com.mysql.jdbc.Connection.createNewIO(Connection.java:2670)I researched on this and found out that I wasn't closing the ResultSet and the PreparedStatement.
    The JDBC connection is closed by a central program that handles connections (custom connection pooling).
    I added the code to close all ResultSets and PreparedStatements, and re-started MySQL as per the instructions here
    but still get "Too many connections" error.
    A few other things come to mind, as to what I may be doing wrong, so I have a few questions:
    1) A few PreparedStatements are created in one method, and they are used in a 2nd method and closed in the 2nd method
    does this cause "Too many connections" error?
    2) I have 2 different ResultSets, in nested while loops where the outer loop iterates over the first ResultSet and
    the inner loop iterates over the second ResultSet.
    I have a try-finally block that wraps the inner while loop, and I'm closing the second ResultSet and PreparedStement
    in the inner while loop.
    I also have a try-finally block that wraps the outer while loop, and I'm closing the first ResulSet and PreparedStatement
    in the outer while loop as soon as the inner while loop completes.
    So, in the above case the outer while loop's ResultSet and PreparedStatements remain open until the inner while loop completes.
    Does the above cause "Too many connections" error?
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The following is relevant sections of my code ( it is partially pseudo-code ) that shows the above 2 cases:
    init( Connection jdbcConnection ){
       String firstSQLStatement = "....";
       PreparedStatement ps1 = jdbcConnection.prepareStatement( firstSQLStatement );
       String secondSQLStatement = "....";
       PreparedStatement ps2 = jdbcConnection.prepareStatement( secondSQLStatement );
       String thirdSQLStatement = "....";
       PreparedStatement ps3 = null;
       ResultSet rsA = null;
       try{
            ps3 = jdbcConnection.prepareStatement( thirdSQLStatement );
            rsA = ps3.executeQuery();
            if( rsA.next() ){
                   rsA.getString( 1 );
       }finally{
            if( rsA != null )
                   rsA.close();
            if( ps3 != null )
              ps3.close();
       //Notice, how ps1 and ps2 are created here but not used immediately, but only ps3 is
       //used immediately.
       //ps1 and ps2 are used in another method.
    run( Connection jdbcConnection ){
         ResultSet rs1 = ps1.executeQuery();
            try{
               while(rs1.next()){
                    String s = rs1.getString();
                    ps2.setString(1, s);
              ResultSet rs2 = ps2.executeQuery();
                    try{
                   while(rs2.next()){
                        String s2 = rs2.getString();
                    }finally{
                   if( rs2 != null )
                     rs2.close();
                   if( ps2 != null )
                     ps2.close();
         }catch( Exception e ){
              e.printStackTrace();
         }finally{
            if( rs1 != null )
                  rs1.close();
               if( ps1 != null )
                  ps1.close();
    //Notice in the above case rs1 and ps1 are closed only after the inner
    //while loop completes.
    }I appreciate any help.

    Thanks for your reply.
    I will look at the central connection pooling mechanism ( which was written by someone else) , but that is being used by many other Java programs others have written.
    They are not getting this error.
    An addendum to my previous note, I followed the instructions here.
    http://dev.mysql.com/doc/refman/5.0/en/too-many-connections.html
    There's probably something else in my code that is not closing the connection.
    But I just wanted to rule out the fact that opening a PreparedStatement in one method and closing it in another is not a problem.
    Or, if nested ResultSet loops don't cause the problem.
    I've read in a few threads taht "Too many connections" can occur for unclosed RS and PS , and not just JDBC connections.

  • Memory problems with PreparedStatements

    Driver: 9.0.1 JDBC Thin
    I am having memory problems using "PreparedStatement" via jdbc.
    After profiling our application, we found that a large number oracle.jdbc.ttc7.TTCItem objects were being created, but not released, even though we were "closing" the ResultSets of a prepared statements.
    Tracing through the application, it appears that most of these TTCItem objects are created when the statement is executed (not when prepared), therefore I would have assumed that they would be released when the ResultSet is close, but this does not seem to be the case.
    We tend to have a large number of PreparedStatement objects in use (over 100, most with closed ResultSets) and find that our application is using huge amounts of memory when compared to using the same code, but closing the PreparedStatement at the same time as closing the ResultSet.
    Has anyone else found similar problems? If so, does anyone have a work-around or know if this is something that Oracle is looking at fixing?
    Thanks
    Bruce Crosgrove

    From your mail, it is not very clear:
    a) whether your session is an HTTPSession or an application defined
    session.
    b) What is meant by saying: JSP/Servlet is growing.
    However, some pointers:
    a) Are there any timeouts associated with session.
    b) Try to profile your code to see what is causing the memory leak.
    c) Are there references to stale data in your application code.
    Marilla Bax wrote:
    hi,
    we have some memory - problems with the WebLogic Application Server
    4.5.1 on Sun Solaris
    In our Customer Projects we are working with EJB's. for each customer
    transaction we create a session to the weblogic application server.
    now there are some urgent problems with the java process on the server.
    for each session there were allocated 200 - 500 kb memory, within a day
    the JSP process on our server is growing for each session and don't
    reallocate the reserved memory for the old session. as a work around we
    now restart the server every night.
    How can we solve this problem ?? Is it a problem with the operating
    system or the application server or the EJB's ?? Do you have problems
    like this before ?
    greetings from germany,

  • PreparedStatement ResultSet wrapper to auto close cursor

    Hi !
    Is it possible to create wrapper that will automatically close result set and prepared statements ?
    I am sick of closing resultsets and preparedstatements in all my dao objects. Its all about neverending try catch and close code lines, it is all against the java garbage collector idea.
    Do you have any workaround ? Or I need to use with those try catch and close.
    Thanks !

    when u allocate object u dont need to call free nor destory when u dont need the object anymore.
    on the other hand, you need to call .close() when u dont need the prepared statement anymore

  • Setting a null(empty) binary stream in a PreparedStatement

    How can I bind a null binary stream into a PreparedStatement?
    In the following, if pMap is null how do I bind it? If I try to serialize a null pMap I get and error that not all columns bound.
    if(pMap == null)
    else
    byte[] _bytes = SerializeUtility.serializeObject(pMap);
    pStatement.setBinaryStream(pColCount, new ByteArrayInputStream(_bytes), _bytes.length);
    Thanks,
    David

    I was too close to the monitor, couldn't see the big picture ! :-) Now it works.
    Although, I still get that Websphere error:
    7c7fc721 SharedPool I J2CA0086W: Shareable connection MCWrapper id 31c73d Managed connection comm.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl@2e55c73d State:STATE_TRAN_WRAPPER_INUSE from resource jdbc/ds was used within a local transaction containment boundary.
    It use to work fine, no errors.
    Any ideeas??
    mihut

  • PreparedStatement and empty String instead of space

    Hi all, I would test a space value in a varchar field, i.e.:
    PreparedStatement ps=con.prepareStatement();
    String qry = "select a from table where b=? and c=?";
    ps.setString(1,"value");
    ps.setString(2," "); // space!!
    That source code doesn't work: it set "" (empty String) in the second field, not " " (space).
    Can I use PrepareStatement in any way to do this or I have to use only Statement?
    Thanks.
    Bye.

    my friend, the question was: how do you know the
    parameter is set to "" (empty string)?I don't know: I suppose!!! because it's the only reason for that it returns no record. I tested my query in this three ways:
    1) directly in sqlplus: SELECT OCCFASE As fase, OCLCVVC as convRat, SUM(QTA1) As qta1UM, SUM(QTA2) As qta2UM
    FROM DJITMPRE WHERE OCCFASE IN ('I','P') AND OCCCOSC='XXXXX' AND OCCITEM='RUG-02' AND OCCTPVR = 'RUG'
    AND OCCVAR1 = '01' AND OCCVAR2 = 'WW' AND OCCVAR3 = '12' AND OCCTPIM = '01' AND MAGAZZINO = 'MAG03'
    AND COMMESSA = ' ' AND ORIG = ' ' AND PARTITA = ' ' AND CONFIG = 0.0 AND VANO = ' '
    GROUP BY OCCFASE, OCLCVVC
    and it returns one record.
    2) using Statement:
         Statement s = conn.createStatement();
         String societa=session.getCompanyLogisticName(DSession.TABLE_LOGISTIC);
              StringBuffer qry=new StringBuffer();
              StringBuffer whereClause=new StringBuffer();
              qry.append("SELECT OCCFASE As fase, OCLCVVC as convRat, SUM(QTA1) As qta1UM, SUM(QTA2) As qta2UM ");
              qry.append("FROM DJITMPRE ");
              qry.append("WHERE OCCFASE IN ('I','P') ");
              qry.append("AND OCCCOSC='");
              qry.append(societa);
              qry.append("' ");     
              whereClause.append("AND OCCITEM='");
              whereClause.append(b.getItemCode());
              whereClause.append("' ");
              whereClause.append("AND OCCTPVR = '");
         if (b.getVariantType().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getVariantType(), 1));
         }else{
              whereClause.append(b.getVariantType());
         whereClause.append("' ");
         whereClause.append("AND OCCVAR1 = '");
         if (b.getFirstVariant().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getFirstVariant(), 1));
         }else{
              whereClause.append(b.getFirstVariant());
         whereClause.append("' ");
         whereClause.append("AND OCCVAR2 = '");
         if (b.getSecondVariant().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getSecondVariant(), 1));
         }else{
              whereClause.append(b.getSecondVariant());
         whereClause.append("' ");
         whereClause.append("AND OCCVAR3 = '");
         if (b.getThirdVariant().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getThirdVariant(), 1));
         }else{
              whereClause.append(b.getThirdVariant());
         whereClause.append("' ");
         whereClause.append("AND OCCTPIM = '");
         if (b.getPackingType().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getPackingType(), 1));
         }else{
              whereClause.append(b.getPackingType());
         whereClause.append("' ");
         whereClause.append("AND MAGAZZINO = '");
         if (b.getWarehouseCode().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getWarehouseCode(), 1));
         }else{
              whereClause.append(b.getWarehouseCode());
         whereClause.append("' ");
         whereClause.append("AND COMMESSA = '");
         if (b.getProjectItem().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getProjectItem(), 1));
         }else{
              whereClause.append(b.getProjectItem());
         whereClause.append("' ");
         whereClause.append("AND ORIG = '");
         if (b.getSourceLot().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getSourceLot(), 1));
         }else{
              whereClause.append(b.getSourceLot());
         whereClause.append("' ");
         whereClause.append("AND PARTITA = '");
         if (b.getLotNumber().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getLotNumber(), 1));
         }else{
              whereClause.append(b.getLotNumber());
         whereClause.append("' ");
         whereClause.append("AND CONFIG = ");
         whereClause.append(b.getItemConfiguration());
         whereClause.append("AND VANO = '");
         if (b.getLocation().equals("")){
              whereClause.append(EscapeString.getLengthString(b.getLocation(), 1));
         }else{
              whereClause.append(b.getLocation());
         whereClause.append("' ");
         qry.append(whereClause.toString());
         qry.append(" GROUP BY OCCFASE, OCLCVVC");
    ResultSet rs = s.executeQuery(qry.toString());
    and it returns one record.
    3) using PreparedStatement:
    StringBuffer qry=new StringBuffer();
    qry.append("SELECT OCCFASE As fase, OCLCVVC as convRat, SUM(QTA1) As qta1UM, SUM(QTA2) As qta2UM ");
                   qry.append("FROM DJITMPRE WHERE OCCFASE IN ('I','P') ");
                   qry.append("AND OCCCOSC='").append(societa).append("' ");
                   qry.append("AND OCCITEM=? AND OCCTPVR = ? ");
              qry.append("AND OCCVAR1 = ? AND OCCVAR2 = ? AND OCCVAR3 = ? ");
              qry.append("AND OCCTPIM = ? AND MAGAZZINO = ? AND COMMESSA = ? ");
              qry.append("AND ORIG = ? AND PARTITA = ? AND CONFIG = ? ");
              qry.append("AND VANO = ? ");
              qry.append("GROUP BY OCCFASE, OCLCVVC");
    PreparedStatement bookedQtyPS = conn.prepareStatement(qry.toString());
    bookedQtyPS.setString(1,b.getItemCode());
         if (b.getVariantType().equals("")){
              bookedQtyPS.setString(2,EscapeString.getLengthString(b.getVariantType(), 1));
         }else{
              bookedQtyPS.setString(2,b.getVariantType());
         if (b.getFirstVariant().equals("")){
              bookedQtyPS.setString(3,EscapeString.getLengthString(b.getFirstVariant(), 1));
         }else{
              bookedQtyPS.setString(3,b.getFirstVariant());
         if (b.getSecondVariant().equals("")){
              bookedQtyPS.setString(4,EscapeString.getLengthString(b.getSecondVariant(), 1));
         }else{
              bookedQtyPS.setString(4,b.getSecondVariant());
         if (b.getThirdVariant().equals("")){
              bookedQtyPS.setString(5,EscapeString.getLengthString(b.getThirdVariant(), 1));
         }else{
              bookedQtyPS.setString(5,b.getThirdVariant());
         if (b.getPackingType().equals("")){
              bookedQtyPS.setString(6,EscapeString.getLengthString(b.getPackingType(), 1));
         }else{
              bookedQtyPS.setString(6,b.getPackingType());
         if (b.getWarehouseCode().equals("")){
              bookedQtyPS.setString(7,EscapeString.getLengthString(b.getWarehouseCode(), 1));
         }else{
              bookedQtyPS.setString(7,b.getWarehouseCode());
    //cat.debug("b.getProjectItem(): "+b.getProjectItem());
         if (b.getProjectItem().equals("")){
              //cat.debug("entro in 1 b.getProjectItem().length: "+b.getProjectItem().length());
              bookedQtyPS.setString(8,EscapeString.getLengthString(b.getProjectItem(), 1));
              //bookedQtyPS.setString(8," ");
         }else{
              //cat.debug("entro in 2 b.getProjectItem().length: "+b.getProjectItem().length());
              bookedQtyPS.setString(8,b.getProjectItem());
         bookedQtyPS.setString(8," ");
    //cat.debug("b.getSourceLot(): "+b.getSourceLot());     
         if (b.getSourceLot().equals("")){
              bookedQtyPS.setString(9,EscapeString.getLengthString(b.getSourceLot(), 1));
         }else{
              bookedQtyPS.setString(9,b.getSourceLot());
         bookedQtyPS.setString(9," ");
    //cat.debug("b.getLotNumber(): "+b.getLotNumber());     
         if (b.getLotNumber().equals("")){
              bookedQtyPS.setString(10,EscapeString.getLengthString(b.getLotNumber(), 1));
         }else{
              bookedQtyPS.setString(10,b.getLotNumber());
         bookedQtyPS.setString(10," ");
    //cat.debug("b.getItemConfiguration(): "+b.getItemConfiguration());
         bookedQtyPS.setString(11,""+b.getItemConfiguration());
    //cat.debug("b.getLocation(): "+b.getLocation());     
         if (b.getLocation().equals("")){
              bookedQtyPS.setString(12,EscapeString.getLengthString(b.getLocation(), 1));
         }else{
              bookedQtyPS.setString(12,b.getLocation());
         bookedQtyPS.setString(12," ");
    ResultSet rs = bookedQtyPS.executeQuery();
    and it returns 0 records.
    I hope I explained it well.

  • PreparedStatement space and empty String

    Hi, I have this problem:
    PreparedStatement bookedQtyPS = null;
    String qry="SELECT * from djwsearch where djwitem=?;
    bookedQtyPS = conn.prepareStatement(qry);
    if(item.equals(""){ //item is an empty String
    bookedQtyPS.setString(1," "); // I set space instead of empty String
    }else{
    bookedQtyPS.setString(1,item);
    My problem is that I need to set space insteadOf empty String, but I think that I can not use PreparedStatement to do this. I have performance problems (my query is much more complicated than this one) so I choose PreparedStatement and not Statement.
    How can I do? Is this bug solved using PreparedStatement?
    Thanks.

    you can do it with the help of PreparedStatement.
    Here the type of field(djwitem) and setmethod is should be match..i mean if the type of ur field is String then you need to use the setSting method.
    you can do one thing specify one string variable.
    String space=" ";
    and now put this sapce variable at the second parameter of setString method.

  • How to retrieve a SQL query (in String format) from a PreparedStatement

    Hello all,
    I am in the process of unit testing an application accessing a Oracle 9i 9.2 RDBMS server with JDBC.
    My query is:
    As I have access to PreparedStatement and CallableStatement Java objets but not to the source queries which help create those objects?
    Is thtere a simple way by using an API, to retrieve the SQL command (with possible ? as placeholders for parameters).
    I have already looked at the API documentation for those two objets (and for the Statement and ResultSetmetaData objects too) but to no avail.
    Thank you for any help on this issue,
    Best regards,
    Benoît

    Sorry for having wasted your time... and for not understanding what you meant in your first reply.
    But the codlet was only to show the main idea:
    Here is the code which compiles OK for this approach to reach its intended goal:
    main class (file TestSuiteClass.java):
    import java.sql.*;
    import static java.lang.Class.*;
    * Created by IntelliJ IDEA.
    * User: bgilon
    * Date: 15/03/12
    * Time: 10:05
    * To change this template use File | Settings | File Templates.
    public class TestSuiteClass {
    public static void main(final String[] args) throws Exception {
    // Class.forName("oracle.jdbc.OracleDriver");
    final Connection mconn= new mConnection(
    DriverManager.getConnection("jdbc:oracle:thin:scott/tiger@host:port:service"));
    * final Statement lstmt= TestedClass.TestedMethod(mconn, ...);
    * final String SqlSrc= mconn.getSqlSrc(lstmt).toUpperCase(), SqlTypedReq= mconn.getTypReq(lstmt);
    * assertEquals("test 1", "UPDATE IZ_PD SET FIELD1= ? WHERE FIELDPK= ?", SqlSrc);
    Proxy class (file mConnector.java):
    import java.sql.*;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Map;
    import java.util.Properties;
    * Created by IntelliJ IDEA.
    * User: bgilon
    * Date: 15/03/12
    * Time: 10:05
    * To change this template use File | Settings | File Templates.
    * This file should be compiled with JDK 1.6, but can be used with previous JDK versions.
    * See OKwith1pN booleans usage for not throwing Exceptions as Unknown methods by the conn object...
    public final class mConnection implements Connection {
    private final Connection conn;
    private final List<Statement> Stmts= new ArrayList<Statement>();
    private final List<String> SqlSrcs= new ArrayList<String>();
    private final List<Integer> TypSrcs= new ArrayList<Integer>();
    private final static String jvmv= System.getProperty("java.specification.version");
    private static final boolean OKwith1p2;
    private static final boolean OKwith1p4; /* OKwith1p5, */
    private static final boolean OKwith1p6;
    static {
    /* jvmv= System.getProperty("java.version");
    System.out.println("jvmv = " + jvmv);
    jvmv= System.getProperty("java.vm.version");
    System.out.println("jvmv = " + jvmv); */
    System.out.println("jvmv = " + jvmv);
    OKwith1p2= (jvmv.compareTo("1.2") >= 0);
    OKwith1p4= (jvmv.compareTo("1.4") >= 0);
    // OKwith1p5= (jvmv.compareTo("1.5") >= 0);
    OKwith1p6= (jvmv.compareTo("1.6") >= 0);
    public String getSqlSrc(final Statement pstmt) {
    int ix= 0;
    for(Statement stmt : this.Stmts) {
    if(stmt == pstmt) return SqlSrcs.get(ix);
    ix+= 1;
    return null;
    static private final String[] TypeNames= new String[] { "Statement", "PreparedStatement", "CallableStatement" };
    public String getTypReq(final Statement pstmt) {
    int ix= 0;
    for(Statement stmt : this.Stmts) {
    if(stmt == pstmt) return TypeNames[TypSrcs.get(ix)];
    ix+= 1;
    return null;
    private void storedStatement(
    final Statement stmt,
    final String sqlSrc,
    final Integer typReq
    Stmts.add(stmt);
    SqlSrcs.add(sqlSrc);
    TypSrcs.add(typReq);
    public Connection getDecoratedConn() {
    return conn;
    mConnection(final Connection pconn) {
    this.conn= pconn;
    public boolean isClosed() throws SQLException {
    return conn.isClosed();
    public void rollback(Savepoint savepoint) throws SQLException {
    if(OKwith1p4) conn.rollback(savepoint);
    public boolean isReadOnly() throws SQLException {
    return conn.isReadOnly();
    public int getTransactionIsolation() throws SQLException {
    return conn.getTransactionIsolation();
    public void setTransactionIsolation(int level)throws SQLException {
    conn.setTransactionIsolation(level);
    public Properties getClientInfo() throws SQLException {
    return OKwith1p6 ? conn.getClientInfo() : null;
    public <T> T unwrap(Class<T> iface)
    throws SQLException {
    return conn.unwrap(iface);
    public void setAutoCommit(boolean auto) throws SQLException {
    conn.setAutoCommit(auto);
    public boolean getAutoCommit() throws SQLException {
    return conn.getAutoCommit();
    public Map<String,Class<?>> getTypeMap() throws SQLException {
    if(!OKwith1p2) return null;
    return conn.getTypeMap();
    public void setTypeMap(Map<String,Class<?>> map) throws SQLException {
    if(!OKwith1p2) return;
    conn.setTypeMap(map);
    public void setHoldability(final int holdability) throws SQLException {
    if(OKwith1p4) conn.setHoldability(holdability);
    public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
    return conn.createStruct(typeName, attributes);
    public void commit() throws SQLException {
    conn.commit();
    public void rollback() throws SQLException {
    conn.rollback();
    public boolean isValid(int timeout) throws SQLException {
    return OKwith1p6 && conn.isValid(timeout);
    public void clearWarnings() throws SQLException {
    conn.clearWarnings();
    public int getHoldability() throws SQLException {
    if(!OKwith1p4) return -1;
    return conn.getHoldability();
    public Statement createStatement() throws SQLException {
    return conn.createStatement();
    public PreparedStatement prepareStatement(final String SqlSrc) throws SQLException {
    if(!OKwith1p2) return null;
    final PreparedStatement lstmt= conn.prepareStatement(SqlSrc);
    storedStatement(lstmt, SqlSrc, 1);
    return lstmt;
    public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
    if(!OKwith1p4) return null;
    final PreparedStatement lstmt= conn.prepareStatement(sql, columnNames);
    storedStatement(lstmt, sql, 1);
    return lstmt;
    public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
    final PreparedStatement lstmt= conn.prepareStatement(sql, resultSetType, resultSetConcurrency);
    storedStatement(lstmt, sql, 1);
    return lstmt;
    public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
    final PreparedStatement lstmt= conn.prepareStatement(sql, columnIndexes);
    storedStatement(lstmt, sql, 1);
    return lstmt;
    public void setClientInfo(String name, String value) throws SQLClientInfoException {
    if(OKwith1p6)
    conn.setClientInfo(name, value);
    public PreparedStatement prepareStatement(final String SqlSrc,
    int resultType,
    int resultSetCurrency,
    int resultSetHoldability) throws SQLException {
    final PreparedStatement lstmt= conn.prepareStatement(SqlSrc, resultType, resultSetCurrency);
    storedStatement(lstmt, SqlSrc, 1);
    return lstmt;
    public PreparedStatement prepareStatement(final String SqlSrc,
    int autogeneratedkeys) throws SQLException {
    if(!OKwith1p4) return null;
    final PreparedStatement lstmt= conn.prepareStatement(SqlSrc, autogeneratedkeys);
    storedStatement(lstmt, SqlSrc, 1);
    return lstmt;
    public CallableStatement prepareCall(final String SqlSrc) throws SQLException {
    final CallableStatement lstmt= conn.prepareCall(SqlSrc);
    storedStatement(lstmt, SqlSrc, 2);
    return lstmt;
    public CallableStatement prepareCall(final String SqlSrc,
    int resultType,
    int resultSetCurrency,
    int resultSetHoldability) throws SQLException {
    if(!OKwith1p4) return null;
    final CallableStatement lstmt= conn.prepareCall(SqlSrc, resultType, resultSetCurrency, resultSetHoldability);
    storedStatement(lstmt, SqlSrc, 2);
    return lstmt;
    public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
    return OKwith1p6 ? conn.createArrayOf(typeName, elements) : null;
    public CallableStatement prepareCall(final String SqlSrc,
    int resultType,
    int resultSetCurrency) throws SQLException {
    if (!OKwith1p2) return null;
    final CallableStatement lstmt= conn.prepareCall(SqlSrc, resultType, resultSetCurrency);
    storedStatement(lstmt, SqlSrc, 2);
    return lstmt;
    public SQLXML createSQLXML() throws SQLException {
    return OKwith1p6 ? conn.createSQLXML() : null;
    public DatabaseMetaData getMetaData() throws SQLException {
    return conn.getMetaData();
    public String getCatalog() throws SQLException {
    return conn.getCatalog();
    public void setCatalog(final String str) throws SQLException {
    conn.setCatalog(str);
    public void setReadOnly(final boolean readonly) throws SQLException {
    conn.setReadOnly(readonly);
    public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
    return conn.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
    public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
    if(!OKwith1p2) return null;
    return conn.createStatement(resultSetType, resultSetConcurrency);
    public String nativeSQL(final String sql) throws SQLException {
    return conn.nativeSQL(sql);
    public void     releaseSavepoint(Savepoint savepoint) throws SQLException {
    if(OKwith1p4) conn.releaseSavepoint(savepoint);
    public Savepoint setSavepoint() throws SQLException {
    return OKwith1p4 ? conn.setSavepoint() : null;
    public Savepoint setSavepoint(final String str) throws SQLException {
    return OKwith1p4 ? conn.setSavepoint(str) : null;
    public boolean isWrapperFor(Class iface) throws SQLException {
    return conn.isWrapperFor(iface);
    public String getClientInfo(final String str) throws SQLException {
    return OKwith1p6 ? conn.getClientInfo(str) : null;
    public void setClientInfo(final Properties pro) throws SQLClientInfoException {
    if (OKwith1p6) conn.setClientInfo(pro);
    public Blob createBlob() throws SQLException {
    return OKwith1p6 ? conn.createBlob() : null;
    public Clob createClob() throws SQLException {
    return OKwith1p6 ? conn.createClob() : null;
    public NClob createNClob() throws SQLException {
    return OKwith1p6 ? conn.createNClob() : null;
    public SQLWarning getWarnings() throws SQLException {
    return conn.getWarnings();
    public void close() throws SQLException {
    conn.close();
    Final word:
    The final word about this is: there is currently three ways to obtain source SQL queries from compiled statement objects.
    a) Use a proxy class the mConnector above;
    b) Use a proxy JDBC driver as Log4JDBC;
    c) Use the trace facility of the driver (however, post analyzing the logs would depend upon the driver selected).
    Thank you for reading,
    Benoît

Maybe you are looking for

  • Error in executing wuery

    iam getting this error in executing query but have closed all the parenthesis create or replace PROCEDURE ProcPCSLabPlusGetAllHMSTest v_Tpname IN VARCHAR2 DEFAULT '%' , cv_1 IN OUT SYS_REFCURSOR AS BEGIN OPEN cv_1 FOR SELECT CODE, DESCR as TPName, 'T

  • Lenovo Launcher v3.2 Update (but in chinese language)

    Hi there, Just want to share what I've found There is an update of lenovo launcher that can be found in here http://launcher.lenovo.com/launcher/portal.php But there are problems It is not good for persons who don't understand Chinese like me The sit

  • Partioning and Running Windows on 10.4.11

    Hey guys, me again. As I said before, I'm trying to get Windows working on my Mac. It seems I bought my Mac just a bit too early before Leapord was released. Anyway, how can I get to Boot Camp or similar? I DO have Disk Utility, but when I attempt to

  • Where can i find the supported events

    i"m looking for the supported event list, i"m having problems with code that run more then one time and i don't know how to stop it.

  • Acquiring remote server access

    I have recently switched to Mac and need to setup a remote login to one of my PC based servers. In the past on PC I have used Remote Desktop Control. Is there a similar app for Mac and please give me as many details as possible. KK