db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Hillegas <Richard.Hille...@Sun.COM>
Subject Re: Caching Prepared Statements
Date Mon, 28 Jul 2008 13:27:31 GMT
Hi Raymond,

I'm not aware of a JDBC method which returns the information you need. I 
ran your experiment on both 10.2 and the current trunk and verified your 
results. The isClosed() method (which PreparedStatement inherits from 
Statement and which was introduced in Java 6) returned false throughout 
the experiment. That was the only method which I thought might give you 
the information you need.

Hope this helps,
-Rick

Raymond Kroeker wrote:
> Hi All,
>     I'm having a big of an issue with my cached prepared statements;
> and would like a little feedback.
>
>     When my application upgrades itself to a new version; it executes
> DDL scripts through my data layer which caches prepared statements.
> When the user jumps 2 versions; you have the following sql:
>
> update META set VALUE='1' where KEY='version';
> alter table META alter column VALUE set data type varchar(256);
> update META set value='2' where KEY='version;
>
> And the original table definition as follows:
> create table META(ID bigint generated always as identity(start with
> 1000),KEY varchar(64) not null,VALUE varchar(128) not null,primary
> key(ID));
>
>     The issue is that when I issue an update on the cached prepared
> statement I get an error of:
> ----------------STACK-BEGIN------------------------
> Caused by: java.sql.SQLException: A PreparedStatement has been
> recompiled and the parameters have changed. If you are using JDBC you
> must prepare the statement again.
> 	at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:95)
> 	at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:203)
> 	at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:380)
> 	at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:345)
> 	at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:1378)
> 	at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:81)
> 	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1272)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(EmbedPreparedStatement.java:1635)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(EmbedPreparedStatement.java:299)
> ----------------STACK-END-------------------------
>
>     My question is as follows; is there a generic (read jdbc) api I
> can use to determine when a statement needs to be dumped from cache?
>
> Derby:  10.2.2.0
> JDK 6.0 u1
> Ubuntu 8.04
>   


Mime
View raw message