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]
Similar Messages
-
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 -
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 BaradwajRaghuram 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 -
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
BhavinHello,
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 -
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
RangaHi
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 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
Leonardocaching 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?
-
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.
SaraPoornima 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.
ThanksPurushothaman 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 -
Db2 - bea jdbc type 4 driver error - cursor not in a prepared state
Hi
I am getting this error from BEA DB2 Driver in weblogic console.
java.sql.SQLException: [BEA][DB2 JDBC Driver][DB2]CURSOR C02 NOT IN A
PREPARED STATE
This problem occurs frequently almost everyday.
When this error happens we clear the statement cache by logging in to the weblogic console (which clears the cache of prepared and callable statements maintained for each connection in the connection pool), and will be able to proceed till the error comes up again!
Has anyone come across this type of error?
DB2 UDB V8.1 Fixpack 4 on Solaris
Weblogic V8.1 SP2
Thanks
Sireesh.We have seen that error as well. When using entity beans, we could do some creates, but then we would get the Cursor error. It would happen sporadically.
IBM now has better Type 4 drivers with version 8.2, we are having better luck with them then with the BEA drivers. -
Use of Prepared Statement in adf
Hi Experts,
I am confused with the Use of prepared statement in adf.
My use case is ,
I have to update a table from every page in my application under certain conditions.
My question is ,
whether I have to create the VO iterator binding in every page and by calling the createinsert and insert the data in to the table or
use a common method in the Application module impl
which is using a prepared statement,(which is not even creating the ViewObject ) like
PreparedStatement st = null;
String sql = "INSERT INTO hr.departments (DEPARTMENT_ID, DEPARTMENT_NAME, MANAGER_ID, LOCATION_ID) VALUES (seq,?,?,?)";
st=getDBTransaction().createPreparedStatement(sql,0);
st.setString(1, name);
st.setString(2, mgr_id);
st.setString(3, Loc_id);
st.execute();
getDBTransaction().commit();which is the best approach?
Studio Edition Version 11.1.1.2.0
RanjithRanjith,
Without further understanding the use case, there's not really much difference between the two approaches. In both cases, you'd have a binding in the page definition (either an iterator binding for the VO or a method binding for the AM service method). Both will use bind variables. The main difference I can see is that, depending on how you have configured your AM pooling settings, the VO method will incur fewer parses in the DB because the AM will cache prepared statements for you.
John -
When to use prepared statement in java?
Hi all,
If we have query like select * from {tablename} (Here tablename is the variable) then will the use of prepared staement improve the performance? My guess is use of statement in this case is a better option rather than prepared statement as the tablename may change for every other query.I think are not useful if tablename changes.They are useful only when the where clause has dynamic values.cantor wrote:
Are you sure that your approach is possible? The next example causes exception for me.
PreparedStatement ps = conn.prepareStatement("select * from ?");
ps.setString(1, "TABLE_NAME");
ps.executeQuery();
I didn't say that he should solve it in that way. He should create one prepared statement like this "select a, b, c from tablename1" and another prepared statement when he wants to execute "select d, e, f from tablename2"
>
And as I understand, this code will not improve perfomance (and even will not work). As I said it can.
Prepared statements make possible usage compiled queries inside DB. When DB gets prepared statement call, it need to parse it only once. And it can collect some statistic to improve execution plan. But when table name is not specified, this approach will not work.Yes it might. There are database drivers that can cache prepared statements and it's isn't likely that he executes that query on more than e.g. 20 tables?
The database can also cache compiled statements in a cache.
Kaj -
Binding in Prepared Statement is not working with Microsoft SQL Server JDBC
I ran the following program with sqljdbc4.jar in the class path. There is data in the EMPLOYEE table for the employee name DEMO but the following program is not retrieving data for DEMO. When the same program was run with Merlia.jar in the class path, it was retrieving data for DEMO.
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con = DriverManager.getConnection("jdbc:sqlserver://SERVER23:5000;databaseName=TESTDB", "SYSADM", "SYSADM");
String sqlSele = "SELECT * FROM EMPLOYEE WHERE EMPNAME like ?" ;
PreparedStatement sts = con.prepareStatement(sqlSele);
sts.setString(1, "DEMO" );
ResultSet rs = sts.executeQuery();
while(rs.next())
System.out.println("driverConn.main()" + rs.toString());
catch(Exception e)
System.out.println(e);
e.printStackTrace();
Can someone help me out from this issue.This is the program that I used for testing the behaviour of prepared statement with sqljdbc4.jar. Also included the code for Merlia.jar.
import java.sql.*;
public class driverConn {
public static void main(String [] a)
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
//Class.forName("com.inet.tds.TdsDriver");
Connection con = DriverManager.getConnection("jdbc:sqlserver://SERVER23:5000;databaseName=TESTDB", "SYSADM", "SYSADM");
//Connection con = DriverManager.getConnection("jdbc:inetdae7a:SERVER23:5000?database=TESTDB", "SYSADM", "SYSADM");
String sqlSele = "SELECT * FROM EMPLOYEE WHERE EMPNAME like ?" ;
//String sqlSele = "SELECT * FROM EMPLOYEE WHERE EMPNAME like ‘%DEMO%’”;
PreparedStatement sts = con.prepareStatement(sqlSele);
sts.setString(1, "DEMO" );
//sts.setString(1, "%DEMO%" );
java.sql.ResultSet rs = sts.executeQuery();
while(rs.next())
System.out.println("EMPNAME is " + rs.getString(“EMPNAME”) + “”); }
catch(Exception e)
System.out.println(e);
e.printStackTrace();
Following are the specifications:
Version of the Driver:
Microsoft JDBC Driver 4.0 for SQL Server CTP3
Downloaded the driver using the link http://www.microsoft.com/download/en/details.aspx?id=11774
Java Version:
Java 1.7.0_02
Database Version:
Microsoft SQL Server 2008 (SP2) - 10.0.4000.0 (X64)
Maybe you are looking for
-
Looking for a J2EE documentation tool
Hello. Before I create this from scratch, I wanted to check if something was already available. I'm trying to create a page that displays the flow of our application's various service calls. The things I want to capture is the reason for the call, th
-
can anyone help please. how do i get the home button to appear on the touch screen my home button has stopped working?
-
CMD+ shortcuts not working in Dreamweaver CS3
I'm have a very strange issue with CMD+ keyboard shortcuts not working in Dreamweaver CS3 on OSX 10.5. These actions are working from the menus (i.e., copy, cut, paste, etc.). CMD+ shortcuts work in other CS3 apps. I've searched this forum and google
-
How to connect to oracle using type4 driver in JSP
i want code to connet to oracle using type 4 driver in JSP
-
HT4060 Is it true you hve to let the IPad battery get real low before you charge it?
I have been told that if I charge the iPad when it is at 1/2 charge that the iPad will start to remember that it needs charged again. I was told the iPad will think it is a in a lower charge than it actually is. So if I charge it every day at 1/2 ch