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

Similar Messages

  • 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

  • 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

  • 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

  • XML SQL format for Prepared statements in batch mode

    Hi
    I want to use the batch mode in JDBC adapter for inserting huge volume of records with better performance.
    so i need to execute the prepared statements in one batch.   Is the XML SQL format for prepared statements below correct ?to<root>
      <stmt>
        <Customers action="SQL_DML">
          <access> INSERT INTO Customers (CompanyName,Address,CustomerID) VALUES($NAME$,$ADDRESS$,$KEYFIELD$)
          </access>
          <key>
            <NAME>IBM</NAME>
            <ADDRESS>Street 3 </ADDRESS>
            <KEYFIELD>CO</KEYFIELD>
          </key>
          <key>
            <NAME>PWC</NAME>
            <ADDRESS>Street 4 </ADDRESS>
            <KEYFIELD>NO</KEYFIELD>
         </key>
        </Customers>
      </stmt>
    </root>
    Please advise

    Hello Experts
    Please throw some light on the above question.
    Thanks in advance.

  • How to implement Startup class for OC4J

    I'm in the process of converting my current J2EE application from weblogic 5.1 to OC4J.
    I have startup class that would set application specific properties by reading property file. In addition, this class would also check for certain resource availability (like database) during weblogic startup. I could not find similar option in OC4J.
    Any help to convert this startup class for OC4J would be highly appreciated.
    Thanks
    Sankaran.

    Hi Sankaran,
    Your eMail address suggests you work for Oracle. Do you? Can't someone
    at Oracle help you?
    I imagine that Oracle would have some kind of agreement with Ironflare
    as well. Can't someone at Ironflare help you?
    But remember, with application servers (as with RDBMSs), no two are the
    same. Each one offers the same functionality, but using different methods
    to achieve that functionality. I don't know how to do it, but I'm sure
    you can check database availability when starting up OC4J -- just not
    the same way you do it in Weblogic.
    Good Luck,
    Avi.

  • 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]

  • Help for prepared statement

    hi,
    I want to usefollowing sql statement by preparedstatment
    select * from tbl_PreServiceManager where (trunc(Activation_Date+30)<trunc(Sysdate) or counter > 0) and CPS<>'FDE'";{code}
    to convert it to prepared statement i did following
    {code}String query="select * from tbl_Pre where (trunc(Activation_Date+30)<trunc(Sysdate) or counter >?) and CPS<>?;"
                pstmt = conn.prepareStatement( query );
                pstmt.setInt(1,0);
                pstmt.setString(2,"FDE");
                rset = pstmt.executeQuery();
    {code}
    but how i manage activation_date with trunc function, infact activation_date field is datetime and i only want to campare date.
    Thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    EG:
    datepart (dp):
    dd ->  day         ->  1-31
    dy ->  day of year ->  1-366
    hh ->  hour        ->  0-23
    mi ->  minute      ->  0-59
    mm ->  month       ->  1-12
    qq ->  quarter     ->  1-4
    ss ->  second      ->  0-59
    ms ->  millisecond ->  0-999
    wk ->  week        ->  0-53
    dw ->  weekday     ->  1-7(Sun - Mon)
    yy ->  year        ->  1753
    SELECT DATEPART(yy,GETDATE()),
           DATEPART(mm,GETDATE()),
           DATEPART(dy,GETDATE())Output
    2008 | 07 | 28

  • 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.

  • How to define my startup class in an .ear package?

    I am using WL6.0SP2 on solaris.
    I plan to package my application as an .ear file and to put all necesarry class
    files in there (it will has one .war file for the web tier and one .jar file for
    the EJBs).
    I want, when Weblogic loads my .ear file (i.e. my application), to execute my
    special startup class, which initializes some caches, etc.
    I do not want to define a startup/shutdown class in the console, because it is
    only specific to my application and this startup class is not present in the weblogic
    classpath during weblogic startup.
    The correct place should be in application.xml, but I don't see such thing in
    the DTD.
    Thank you,
    Ivaylo Zlatev

    There is no way to do this on the EAR level - you can use load-on-startup
    servlet(s) in your web component, or initial-beans-in-free-pool=1 EJB.
    Ivaylo Zlatev <[email protected]> wrote:
    I am using WL6.0SP2 on solaris.
    I plan to package my application as an .ear file and to put all necesarry class
    files in there (it will has one .war file for the web tier and one .jar file for
    the EJBs).
    I want, when Weblogic loads my .ear file (i.e. my application), to execute my
    special startup class, which initializes some caches, etc.
    I do not want to define a startup/shutdown class in the console, because it is
    only specific to my application and this startup class is not present in the weblogic
    classpath during weblogic startup.
    The correct place should be in application.xml, but I don't see such thing in
    the DTD.
    Thank you,
    Ivaylo Zlatev--
    Dimitri

  • 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

  • Problems with Deployment, Startup classes and MBeanHome

    Hello,
    we have the following problem: How to initialize our application
    correctly???
    We are using MDBs as message consumers but have to guarantee the order of
    incoming
    messages. Due to a shortcoming in the JMS implementation (Order of
    redelivered messages
    is not guaranteed before WLS 8.1!!!) we are using a singleton class to keep
    the health state
    of the different message queues within the application (controlling whether
    the MDBs are
    supposed to proceed with processing or to discard any incoming messages).
    Thus the MDBs
    have to access this singleton, what implies latter has to be initialized
    prior to the application
    deployment. That's what we are using a startup class for, which is marked to
    be loaded before
    appplication deployment...
    Fortunately the according bug is fixed with WLS 7.0.2.0, so the class is
    loaded, but we are
    not able to access the MBeanHome interface (We like to register MBean to
    provide
    adminstrative access to the health state)!!!
    javax.naming.NameNotFoundException: Unable to resolve
    'weblogic.management.home.localhome' Resolved: 'weblogic.management'
    Unresolved:'home' ; remaining name 'home.localhome'
    at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:174)
    So when is the MBeanServer started???
    Before application deployment??? After??? Is there any way to tell WLS not
    to load the startup
    class before the MBeanServer is available respectively the MBeanHome is
    accessible via JNDI
    but before application deployment???
    Any hints are welcome!!!
    Regards,
    CK

    this seems like a bug. the mbeanhome should be available for lookup in
    startup classes. also posting to system management newsgroup.
    "Carsten Kaiser" <[email protected]> wrote in message
    news:[email protected]..
    Hello,
    we have the following problem: How to initialize our application
    correctly???
    We are using MDBs as message consumers but have to guarantee the order of
    incoming
    messages. Due to a shortcoming in the JMS implementation (Order of
    redelivered messages
    is not guaranteed before WLS 8.1!!!) we are using a singleton class tokeep
    the health state
    of the different message queues within the application (controllingwhether
    the MDBs are
    supposed to proceed with processing or to discard any incoming messages).
    Thus the MDBs
    have to access this singleton, what implies latter has to be initialized
    prior to the application
    deployment. That's what we are using a startup class for, which is markedto
    be loaded before
    appplication deployment...
    Fortunately the according bug is fixed with WLS 7.0.2.0, so the class is
    loaded, but we are
    not able to access the MBeanHome interface (We like to register MBean to
    provide
    adminstrative access to the health state)!!!
    javax.naming.NameNotFoundException: Unable to resolve
    'weblogic.management.home.localhome' Resolved: 'weblogic.management'
    Unresolved:'home' ; remaining name 'home.localhome'
    at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:174)
    So when is the MBeanServer started???
    Before application deployment??? After??? Is there any way to tell WLS not
    to load the startup
    class before the MBeanServer is available respectively the MBeanHome is
    accessible via JNDI
    but before application deployment???
    Any hints are welcome!!!
    Regards,
    CK

  • 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

  • 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

  • Error handling in prepared statement batch

    Hi,
    For a prepared statement batch, it is not possible to know which operation failed. ... You should always perform a ROLLBACK operation in this situation.
    For a generic statement batch or callable statement batch, the update counts array is only a partial array containing the actual update counts up to the point of the error. ... You can either commit or roll back the successful operations in this situation, as you prefer.
    -- http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/java.920/a96654/oraperf.htm#1056233
    But, I want to skip failed operations and continue to excecute the remains of the batch, also, I want to improve application performance, what should I do? Is there any choice?
    Best Regards,
    Kevin Zhao

    According to the Oracle docs these are not the only possible values:
    Oracle9i JDBC Developer's Guide and Reference
    Release 2 (9.2) chapter 12
    Performance Extensions
    "For a prepared statement batch, it is not possible to know which operation failed. The array has one element for each operation in the batch, and each element has a value of -3. According to the JDBC 2.0 specification, a value of -3 indicates that an operation did not complete successfully. In this case, it was presumably just one operation that actually failed, but because the JDBC driver does not know which operation that was, it labels all the batched operations as failures."
    It goes on to say that for a generic statement batch it is possible to know which failed. I would like to know if similar functionality will be available for prepared statement batches in the future.

Maybe you are looking for

  • Help!  Kernel panic when I empty my trash.

    I have 500GB disk. Unknowingly, I have filled it up. Now I only have 12GB left. I tried to clean up by removing some of my old iMovieProject file. I deleted a 20GB file and now the computer just panic when I try to empty the trash. It asks me to rese

  • Export just responses to another PDF file

    The answer here may be obvious, but I can't see it. I have a very large form with many check boxes and fillin values. I would like to create anotehr PDF form that is just a quick summary form, that can import just specific response from the larger fo

  • Bapi for creation of a contract against services.

    Hi. i just want to know the correct bapi for creation of contracts against services..here i was tried with BAPI_CONTRACT_CREATE but the documentation says that it is not supported for exxternal or internal services. so iam not sure if this bapi is th

  • Read from a file and execute the statement

    Hi I have a .sql file that contains insert statements. I would like to open the file, read a statement and execute it using a procedure. Can sombody help me out?

  • How do I open Photoshop Elements 12

    I have an old Adobe Photo Shop Album Starter 3.2 that is locked up all my photos in my windows XP computer. I tried to register it again but got nowhere. The phone and chat room to Adobe was of no help. I just downloaded a trial version of Element 12