Prepared statement cache & Oracle

Hi -
Does Weblogic's prepared statement caching only work when using their
type-2 Oracle driver? Are there any documents about using this
Weblogic feature? I have only found small references in the Weblogic
documentation so far -- nothing with much detail.
Thanks for any help,
- Mark

"Joseph Weinstein" <[email protected]> wrote in message
news:[email protected]..
>
>
Mark Cassidy wrote:
Hi -
Does Weblogic's prepared statement caching only work when using their
type-2 Oracle driver?No. It is generic to JDBC. Any JDBC driver should allow re-use ofPreparedStatements,
and our pool will cache for any driver.
Are there any documents about using this
Weblogic feature? I have only found small references in the Weblogic
documentation so far -- nothing with much detail.You are correct that there is too little documentation at this time.
Thanks for any help,
- Mark
Thanks Joe!
Do you know if each connection's cache is FIFO? Or do you use
least-recently-used algorithm?
I found one comment you made regarding XA pools. That means that if we are
doing 2-phase commit processing that some of these benefits could erode? I
didn't understand why. If we assume that the connections in a given pool
after a time get a good sampling of popular prepared statements, would their
being XA or not matter? Maybe I missed your point entirely.
- Mark

Similar Messages

  • Jboss getting SQLException: Closed Statement prepared-statement- cache-size

    My first post in this forum , hope to get a quick resolution :)
    I am using Jboss 4.0.0 on Oracle 9.2.0.4.0
    In order to improve the app performance , I had specified prepared-statement-cache-size as 50 as follows ,
    <datasources>
    <local-tx-datasource>
    <jndi-name>jdbc/sct</jndi-name> <connection-url>jdbc:oracle:thin:@confidential:1560:sct1</connection-url>
    <user-name>Confidential</user-name>
    <password>Confidential</password>
    <min-pool-size>10</min-pool-size>
    <max-pool-size>120</max-pool-size>     <prepared-statement-cache-size>50</prepared-statement-cache-size>
    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptio nSorter</exception-sorter-class-name>
    <idle-timeout-minutes>5</idle-timeout-minutes>
    <track-statements>true</track-statements>
    <new-connection-sql>select sysdate from dual</new-connection-sql>
    <check-valid-connection-sql>select sysdate from dual</check-valid-connection-sql>
    </local-tx-datasource>
    </datasources>
    After doing this , I start getting the following exception ,
    java.sql.SQLException: Closed Statement
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:222)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:285)
         at oracle.jdbc.driver.OracleStatement.ensureOpen(OracleStatement.java:5681)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.j ava:409)
         at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.ja va:366)
         at org.jboss.resource.adapter.jdbc.CachedPreparedStatement.executeQuery(CachedPrepare dStatement.java:57)
         at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPrepa redStatement.java:296)
         at com.ge.sct.SiteText.getSiteTextFromDB(SiteText.java:292)
    Thanks in Advance
    Bhavin

    Hello,
    I am also facing the same error: somewhere just now I read,
    We were getting this error on JBoss / Oracle. The fix was setting the following to 0 in oracle-ds.xml:
    <prepared-statement-cache-size>0</prepared-statement-cache-size>
    Ref: http://www.jpox.org/servlet/forum/viewthread?thread=1108
    May be you can try this, I am also still finding the solution, I will try the above and let u know, if i get success.
    Regards,
    Rajesh

  • How to retrieve a prepared statement from prepared statement cache?

    Hi All,
    I have created the connection pool during application server startup. The connection pool are getting created successfully. I have also created the prepared statements and stored as part of each connection in the connection pool.
    can anyone please tell me on how do I retrieve a prepared statement from prepared statement cache from a connection object.
    Any pointers to info source will be REALLY appreciated.
    Many Thanks in Advance,
    C R Baradwaj

    Raghuram Bharatwaj C wrote:
    Hi Joe,
    I have created a connection poool in my startup class and created the
    neccessary prepared statements for a each connection. I have 10 prepared
    statements to be created for each connection. I have created all the 10 prepared statements using the loop as mentioned below
    String [] epc_stmts;
    private java.sql.PreparedStatement[] _pstmts;
    if (epc_stmts!= null)
                   _pstmts = new PreparedStatement [len = epc_stmts.length];
                   for (i=0; i<len; i++)
                        _pstmts[i] = db.prepareStatement (epcstmts);
    I have closed the connection after the prepared statements are created.
    Now, How do i access a prepared statement from the connection object.
    Nothing. Are you talking about a WebLogic pool? If so, then therafter,
    whenever your application gets a pool connection, when it calls
    prepareStatement() with the same SQL as you prepared those statements,
    it will get a cached statement. Your array is unnecessary.
    Joe
    >
    Many Thanks in Advance,
    C R Baradwaj

  • Startup class for prepared statement cache

    Hi
    we are using weblogic 7.0 sp1 . As clearcacheparamters method is not available
    with this version ,we have written a startup class to cache the preparedstaments
    that we need ,even then these statements are not getting cached .we have observed
    the oracle trace,it is parsing the prepared statement each time we make a call.Can
    anyone clarify where iam doing wrong and suggest me a way to cache the prepared
    statements we wanted.
    my sample startup class looks like this
    Collection connections = new ArrayList();
    int conCount = 0;
    Connection con =null;
    PreparedStatement prep1=null;
    PreparedStatement prep2=null;
    PreparedStatement prep3=null;
    while(true)
    try
    con = SQLConnection.getConnection();
    connections.add(con);
    prep1 = con.prepareStatement(sql1);
    prep2 = con.prepareStatement(sql2);
    prep 3 = con.prepareStatement(sql3);
    conCount++;
    catch (SQLException e)
    System.out.println("exception SQLException "+e.getMessage());
    break;
    catch (IOException e)
    System.out.println("******StartUp Connections got ---> "+conCount);
    try
    Iterator connectionIt = connections.iterator();
    while(connectionIt.hasNext())
    con = (Connection) connectionIt.next();
    con.close();
    catch (SQLException e)
    we cant upgrade to sp3 immediately ,so please provide a solution for weblogic
    7.0 sp1.
    Thanks & Regards
    Ranga

    Hi
    we are using weblogic 7.0 sp1 . As clearcacheparamters method is not available
    with this version ,we have written a startup class to cache the preparedstaments
    that we need ,even then these statements are not getting cached .we have observed
    the oracle trace,it is parsing the prepared statement each time we make a call.Can
    anyone clarify where iam doing wrong and suggest me a way to cache the prepared
    statements we wanted.
    my sample startup class looks like this
    Collection connections = new ArrayList();
    int conCount = 0;
    Connection con =null;
    PreparedStatement prep1=null;
    PreparedStatement prep2=null;
    PreparedStatement prep3=null;
    while(true)
    try
    con = SQLConnection.getConnection();
    connections.add(con);
    prep1 = con.prepareStatement(sql1);
    prep2 = con.prepareStatement(sql2);
    prep 3 = con.prepareStatement(sql3);
    conCount++;
    catch (SQLException e)
    System.out.println("exception SQLException "+e.getMessage());
    break;
    catch (IOException e)
    System.out.println("******StartUp Connections got ---> "+conCount);
    try
    Iterator connectionIt = connections.iterator();
    while(connectionIt.hasNext())
    con = (Connection) connectionIt.next();
    con.close();
    catch (SQLException e)
    we cant upgrade to sp3 immediately ,so please provide a solution for weblogic
    7.0 sp1.
    Thanks & Regards
    Ranga

  • Prepared Statement Cache in WLAS 6.0 sp2

    Does 6.0 sp2 cache prepared statements like 6.1.
    I have heard yes and no and if so is there a way to disable it like in
    6.1

    Larry Presswood wrote:
    >
    Ok so is there a way to disable it in 6.0 sp2 that you know of??To disable it, add this jar file to the front of the server's classpath.
    Joe
    >
    Cameron Purdy wrote:
    It's been there since 5.1 (sp6 or sp9?)
    Peace,
    Cameron Purdy
    Tangosol, Inc.
    Clustering Weblogic? You're either using Coherence, or you should be!
    Download a Tangosol Coherence eval today at http://www.tangosol.com/
    "Larry Presswood" <[email protected]> wrote in message
    news:[email protected]..
    Does 6.0 sp2 cache prepared statements like 6.1.
    I have heard yes and no and if so is there a way to disable it like in
    6.1
    [60nocache.jar]

  • Prepared Statements and Oracle functions:

    Consider this code:
    String searchText = "someInputText";
    StringBuffer sqlstmt = new StringBuffer();
    sqlstmt.append("SELECT ID_FIELD FROM ");
    sqlstmt.append("MY_TABLE WHERE NAME_FIELD ");
    sqlstmt.append("like INITCAP('%" + searchText + %')");
    PreparedStatement ps = con.prepareStatement(sqlstmt.toString());This works fine like this, but when I replace the searchText in the sqlstmt to ? it doesn't work:
    sqlstmt.append("like INITCAP('?')");
    PreparedStatement ps = con.prepareStatement(sqlstmt.toString());
    ps.setString(1, "%" + searchText + "%");How do you use the PreparedStatement with a
    function like INITCAP where you need to use a
    dynamic ? in the sql statement?
    Thanks,
    Rob.

    Very easy to miss this.
    Don't put the percentages IN the SQL statement.
    Append the percentages to your string.
    Like this:
    String searchText = "%" + "someInputText" + "%";
    StringBuffer sqlstmt = new StringBuffer();
    sqlstmt.append("SELECT ID_FIELD FROM ")
           .append("MY_TABLE WHERE NAME_FIELD ")
           .append("like INITCAP(?)");
    PreparedStatement ps = con.prepareStatement(sqlstmt.toString());
    ps.setString(1, searchText);
    resultSet = ps.executeQuery();Wish I saw this earlier for you.

  • Prepared Statement Flooding

    Hi Friends,
    Need your help to fix this prolonging problem in one of our applications. We observe that the following queries are declared as prepared statements but have dynamic value ROWID in each.
    SELECT ROWID, C. * FROM Table1 C WHERE C.VENDORLOGINID = ? AND C.VENDORTYPE = ? AND (ROWID = _ ROWID100)
    SELECT ROWID, C. * FROM Table2 C WHERE C.VENDORIDCH = ? AND (ROWID = _ ROWID114)
    SELECT ROWID, C. * FROM Table1 C WHERE C.VENDORLOGINIDBASE = ? AND C.VENDORTYPE = ? AND (ROWID = _ ROWID58)
    This results in a FLOOD of prepared statements (over 3000) as it is an application with a very large DB.
    We found out that a newer version of Ojdbc14.jar (10.2.0.3.0) is available (At present we are shipping the product with 10.2.0.1.0). We tested with this newer jar and found out bind variables are not treated as dynamic variables with this jar file. SQL queries are getting cached as expected.
    This new jar file did fix the problem when our DB was 10g for the application (another), but for this current application we are using Oracle 9i.
    The same jar file does not seem to be fixing the issue.
    Has anybody faced similar issue before?
    Ideally the 10g jar file should eb backward compatible but for some reason it is not for this particular problem.
    Please can somebody help to get a solution for this problem. Do let me know if you need more information.
    Thanks.

    Poornima wrote:
    Is the prepared statement cache common to all the Connection objects in the Connection Pool or is there a separate cache for each statement in the Connection Pool?There is a separate statement cache for each connection in the pool.
    Joe

  • Callable Statement Cache Size

    Hi all,
    while using some dinamyc store procedures I get in the following error:
    [BEA][SQLServer JDBC Driver]Value can not be converted to requested type.
    I'm using WL8.1 and Sql Server 2000.
    Store procedure contains two different queries where table name is a store procedure's
    parameter.
    The first time it works great, after that I always have this error:
    Reading bea doc's I found
    There may be other issues related to caching prepared statements that are not
    listed here. If you see errors in your system related to prepared statements,
    you should set the prepared statement cache size to 0, which turns off prepared
    statement caching, to test if the problem is caused by caching prepared statements.
    If I set prepared statement cache size to 0 everything works great but that does
    not seem the better way.
    Should we expect Bea to solve this problem?
    Or whatever else solution?
    such as using JDBCConnectionPoolMBean.setPreparedStatementCacheSize()
    dynamically ?
    thks in advance
    Leonardo

    caching works well for DML and thats what it is supposed to do. But it looks
    like you are doing DDL , which means your tables might be getting
    created/dropped/altered which effectively invalidates the cache. So you
    should try to turn the cache off.
    "leonardo" <[email protected]> wrote in message
    news:40b1bb75$1@mktnews1...
    >
    >
    Hi all,
    while using some dinamyc store procedures I get in the following error:
    [BEA][SQLServer JDBC Driver]Value can not be converted to requested type.
    I'm using WL8.1 and Sql Server 2000.
    Store procedure contains two different queries where table name is a storeprocedure's
    parameter.
    The first time it works great, after that I always have this error:
    Reading bea doc's I found
    There may be other issues related to caching prepared statements that arenot
    listed here. If you see errors in your system related to preparedstatements,
    you should set the prepared statement cache size to 0, which turns offprepared
    statement caching, to test if the problem is caused by caching preparedstatements.
    If I set prepared statement cache size to 0 everything works great butthat does
    not seem the better way.
    Should we expect Bea to solve this problem?
    Or whatever else solution?
    such as using JDBCConnectionPoolMBean.setPreparedStatementCacheSize()
    dynamically ?
    thks in advance
    Leonardo

  • Pooling Prepared Statement and Resultset

    Is their any mechanism in Weblogic by which we can pool prepared statements and
    resultset.

    Yes you can cache prepared statements. The connection pool will
    automatically cache the prepared statements (10 prepared statement was the
    limit in previous so you may want to write some startup class to load the
    imp prepared statements.). When you reuse the prepared statement the
    connection pool will pick it from its prepared statement cache. In 6.1 you
    can configure the number of prepared statements that you want to cache.
    But you cannot have multiple resultsets open for the same statement object.
    You can have cache rows though.
    Please search the bea newsgroups for more info. There are a bunch of posts
    that will be helpful to you.
    http://search.bea.com/weblogic/gonews/
    sree
    "hogan" <[email protected]> wrote in message
    news:3bd9cf88$[email protected]..
    >
    Is their any mechanism in Weblogic by which we can pool preparedstatements and
    resultset.

  • Prepared Statement - Using IN()

    Does anybody have a good solution to using an IN clause in a preapred Statement?
    The query I have might be "Select * from dual where 1 IN(1,2,3,4);"
    OR
    "Select * from dual where 1 IN(1,2,3,4, 5, 6, 7);"
    OR
    "Select * from dual where 1 IN(n number of arguments);"
    So I don't know how to parameterize this to take advantage of prepared statements.
    Does anybody have any solutions?

    So if you can't use IN with prepared statements, then is it better not to use prepared statements so we don't blow through the prepared statement cache?

  • Weblogic and prepared statement

    We had an odd situation in production. We had a situation where we would always get a ORA-00904 Invalid Column name when running the following bit of code (via the prepared statement):
                   preparedStatement = con.prepareStatement("select * from KO_USER where GLOBAL_ID=?");
                   preparedStatement.setInt(1,thisGlobalId);
                   rs = preparedStatement.executeQuery();
    But when we simply converted it to a regular statement, as below, it ran fine.
                   preparedStatement = con.createStatement();
                   rs = preparedStatement.executeQuery("select * from KO_USER where GLOBAL_ID="+thisGlobalId);
    Can anyone explain this behavior? We use prepared statements throughout our codebase and never had a problem with it before.
    Thanks for any insight.
    Sara

    Poornima wrote:
    Is the prepared statement cache common to all the Connection objects in the Connection Pool or is there a separate cache for each statement in the Connection Pool?There is a separate statement cache for each connection in the pool.
    Joe

  • Oracle Cached Prepared Statement

    We recently upgraded from WL 8.1 SP3 to WL 9.2 and in the process updated the JDBC Driver for Oracle from 10.2.0.1 to 10.2.0.2. After we went live we started seeing issue in one table. The table contains some special character which is not suppose to be there.
    Here is the code & table details
    PreparedStatement pstmt = cn.prepareStatement("INSERT INTO INFO_TABLE(user_name,user_status) values (?,?)");
    pstmt.setString(1,requestObject.getUserName());
    if(requestObject.isValidUser)
    pstmt.setInt(2,requestObject.getStatus());
    }else
    pstmt.setNull(2,Types.VARCHAR);
    cn.commit();
    Table description:
    USER_NAME VARCHAR2(60);
    USER_STATUS VARCHAR2(5);
    - The USER_STATUS columns valid values are 0-4 or NULL.
    The problem is on certain occasions the valid user value in the table is some special character. I got the ascii value of this character as 128. We don't know yet whether setting int value and varchar (null) value on two different flow (but cached prepared statement) is the issue.
    We can fix the code to use uniform data type but we need to be sure this is what causing the problem. Further when I read the docs http://e-docs.bea.com/wls/docs90/jdbc_admin/jdbc_datasources.html
    I can associate the problem I face with this pointer however as I said, we need some sort of confirmation to make this change in the production code.
    Here is what I am specifically looking for
    1. Is there a way to confirm this problem?
    2. Can we log the prepared statement being executed and the binded value being sent to the Oracle DB?
    I suspect the VARCHAR null type is being casted to int value 128.
    Would really appreciate any pointers on this.
    Thanks

    Purushothaman Thambu wrote:
    We recently upgraded from WL 8.1 SP3 to WL 9.2 and in the process updated the JDBC Driver for Oracle from 10.2.0.1 to 10.2.0.2. After we went live we started seeing issue in one table. The table contains some special character which is not suppose to be there.
    Here is the code & table details
    PreparedStatement pstmt = cn.prepareStatement("INSERT INTO INFO_TABLE(user_name,user_status) values (?,?)");
    pstmt.setString(1,requestObject.getUserName());
    if(requestObject.isValidUser)
    pstmt.setInt(2,requestObject.getStatus());
    }else
    pstmt.setNull(2,Types.VARCHAR);
    cn.commit();
    Table description:
    USER_NAME VARCHAR2(60);
    USER_STATUS VARCHAR2(5);
    - The USER_STATUS columns valid values are 0-4 or NULL.
    The problem is on certain occasions the valid user value in the table is some special character. I got the ascii value of this character as 128. We don't know yet whether setting int value and varchar (null) value on two different flow (but cached prepared statement) is the issue.
    We can fix the code to use uniform data type but we need to be sure this is what causing the problem. Further when I read the docs http://e-docs.bea.com/wls/docs90/jdbc_admin/jdbc_datasources.html
    I can associate the problem I face with this pointer however as I said, we need some sort of confirmation to make this change in the production code.
    Here is what I am specifically looking for
    1. Is there a way to confirm this problem?
    2. Can we log the prepared statement being executed and the binded value being sent to the Oracle DB?
    I suspect the VARCHAR null type is being casted to int value 128.
    Would really appreciate any pointers on this.
    ThanksHi. I don't think there's any issue with WebLogic here, but the code you show
    might confuse some drivers. I highly recommend using setString for all
    varchar/char/varchar2 columns, not setInt(). If requestObject.getStatus()
    has to return an int, try this:
    if(requestObject.isValidUser)
    pstmt.setString(2, (""+ requestObject.getStatus()) );
    Joe

  • How to use Oracle statement cache?

    hi,
    I'm using weblogic 7 with the included Oracle JDBC Thin driver
    (9.2.0).
    One new(?) feature in this driver statement caching, but it seems that
    weblogic does not support this feature.
    Mainly the classes in weblogic.jdbc.vendor.oracle.* that are some sort
    of wrapper(?) to the thin driver does not support the methods that
    enable this.
    The driver docs says to use
    OracleConnection.setImplicitStatementCachingEnabled(true)
    or
    OracleConnection.setExplicitStatementCachingEnabled(true)
    but these just don't exist in the
    weblogic.jdbc.vendor.oracle.OracleConnection class.
    So, is this feature not supported by weblogic or there's another way
    of doing statement caching?
    Thanks
    anat

    anat wrote:
    hi,
    I'm using weblogic 7 with the included Oracle JDBC Thin driver
    (9.2.0).
    One new(?) feature in this driver statement caching, but it seems that
    weblogic does not support this feature.
    Mainly the classes in weblogic.jdbc.vendor.oracle.* that are some sort
    of wrapper(?) to the thin driver does not support the methods that
    enable this.You are correct. Our oracle interface doesn't have that call, so you can't enable it.
    Our next major release (in beta now) will allow you do do anything the driver
    provides. For now, we do provide the same sort of functionality in our pool.
    If you set the pool's statement cache size to N, then we will cache up to N
    prepared statements for each pooled connection. This will get you exactly the
    same performance benefit.
    Joe
    >
    >
    The driver docs says to use
    OracleConnection.setImplicitStatementCachingEnabled(true)
    or
    OracleConnection.setExplicitStatementCachingEnabled(true)
    but these just don't exist in the
    weblogic.jdbc.vendor.oracle.OracleConnection class.
    So, is this feature not supported by weblogic or there's another way
    of doing statement caching?
    Thanks
    anat

  • Oracle Prepared Statement and spaces in field

    I have a field that is defined as char(10). It has characters like '39' in it. When I select against it using standard SQL (where clause) I get results. When I use it in the where clause of a prepared statement it does not return any rows.
    If I have the field defined as char(2) the prepared statement works.
    If I have the field defined as varchar2(10) and loaded with '39' the prepared statement works.
    If I have the field defined as varchar2(10) and loaded with '39 ' the prepared statement returns no results.
    I really do not think this is a JDBC problem. However, since Oracle's site basically <expletive deleted>, I am hoping someone here has a solution.
    Thanks in advance if you can help.

    Let me clarify.
    I cannot remove the whitespace from the data in the database. I do not need the whitespace to do the query if I am not using a Prepared Statement. This seems to be a problem with the way Oracle is handling the prepared statement. (hence.. my thinking that this is really not a JDBC problem at all.. but I could be wrong.)

  • Using once created prepared statement with different connections in Oracle

    Can I use same statement cash using different connections in Oracle
    For example I have a prepared statement p1. After its using i close connection (return it to the pool)
    Next time I want use p1 statement using another connection.
    Question : When I creat p1 in second time ,is it returned from cash or created as a new statement. And what I should do to use once prepared statement using differend connections.
    Thaks.

    As far as I know a PreparedStatement lives and dies with the Connection that created it. So, you cannot use a PreparedStatement with other Connection instances than the one that created it.
    You will have to recreate the PreparedStatement for each time you open a connection, or use the same PreparedStatement and NOT close the Connection in between. The last suggestion can be risky though, if you never close the connection...
    Jakob Jenkov
    www.jenkov.com

Maybe you are looking for

  • Using D-Link DI-624 Router for "G" Wireless Purposes

    I want to use an old D-link router in another part of the house to provide wireless "G" connectivity to my older devices, so I can use 5 GHz band for "N" connectivity exclusively via my Airport Extreme (Older version, not Gigabit). I go upstairs, plu

  • Oracle RAC 11g R2 installation complete installation guide

    Hi, Please suggest any oracle docs for Oracle RAC 11g R2 installation complete installation. I am in process for installating Oracle RAC 11g r2 first time in my life this weekend.please help.

  • HOW TO CONNECT ORACLE BI DISCOVERER ADMINISTRATOR 10g

    Hi, My question is HOW TO CONNECT ORACLE BI DISCOVERER ADMINISTRATOR 10g. I know how to connect PLUS and VIEWER using a URL. Do i need to install Discoverer Admin. separately on my local machine. This is very urgent... Please reply. Thanks in advance

  • IDOC Inbound processing -  Port Error

    Hi , I am working on Setting up a Standard IDOC Communication from Middle ware to SAP. I have set-up Logical System, RFC Destinations for SAP And Middleware, Port for SAP and Middleware and Partner Profile. I tested Middleware and SAP RFC destination

  • Join two partitions

    How to I join t wo partitions in sun solaris 9.0 because of lack of space I wanted to delete one partition and join that space to another one. Please guide me on this.. Thank you, PNRAJ