Hello all,

I am getting this exception when I declare the following class
variables:

private static Connection connection = null;
private static PreparedStatement queryProductSummary = null;

and then try to execute this code within that class twice in a row (a
message driven bean calls this code):

public static Document getProductSummary(String participantID, int
productID) throws Exception{
        Document result = null;
        
        prepareConnection();   
        if(queryProductSummary == null){
            log.info("preparing statement");
            queryProductSummary = connection.prepareStatement("SELECT
product_summary_xml " + 
                    " FROM product_summary_xml " + 
                    " WHERE participant_id = ? " + 
                    " AND product_id = ? ");
        }
      
        queryProductSummary.clearParameters();
        queryProductSummary.setString(1, participantID);
        queryProductSummary.setInt(2, productID);

        ResultSet rs = queryProductSummary.executeQuery();
        
        ...
        
        return result;
    }
    
    public static void prepareConnection() throws SQLException{
        if(connection == null || connection.isClosed())
            connection = OracleDataSource.getConnection();
    }

I realize it is good practice to close statements and connections, but
in this case I wanted to keep them open across multiple calls.

I have been reading in the forums that this seems to be a JBoss issue,
but I want to make sure I am not doing anything blatantly incorrect.  I
am using JBoss4.0alpha.

Here is the exception:

16:18:19,047 ERROR [STDERR] java.sql.SQLException: Connection handle is
not currently associated with a ManagedConnection
16:18:19,047 ERROR [STDERR]     at
org.jboss.resource.adapter.jdbc.WrappedConnection.checkStatus(WrappedCon
nection.java:774)
16:18:19,047 ERROR [STDERR]     at
org.jboss.resource.adapter.jdbc.WrappedConnection.checkTransaction(Wrapp
edConnection.java:755)
16:18:19,047 ERROR [STDERR]     at
org.jboss.resource.adapter.jdbc.WrappedStatement.checkTransaction(Wrappe
dStatement.java:771)
16:18:19,047 ERROR [STDERR]     at
org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(Wr
appedPreparedStatement.java:286)
16:18:19,047 ERROR [STDERR]     at
com.scilearn.db.ProductSummary.getProductSummary(ProductSummary.java:204
)
16:18:19,047 ERROR [STDERR]     at
com.scilearn.db.ProductSummary.getExerciseSummaries(ProductSummary.java:
184)
16:18:19,047 ERROR [STDERR]     at
com.scilearn.beans.UploadQueueListener.onMessage(UploadQueueListener.jav
a:119)
16:18:19,047 ERROR [STDERR]     at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
16:18:19,047 ERROR [STDERR]     at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
16:18:19,047 ERROR [STDERR]     at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
16:18:19,047 ERROR [STDERR]     at
java.lang.reflect.Method.invoke(Method.java:324)
16:18:19,057 ERROR [STDERR]     at
org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(Message
DrivenContainer.java:405)
16:18:19,057 ERROR [STDERR]     at
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(
CachedConnectionInterceptor.java:187)
16:18:19,057 ERROR [STDERR]     at
org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterce
ptor.java:108)
16:18:19,057 ERROR [STDERR]     at
org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext(AbstractTxInte
rceptorBMT.java:144)
16:18:19,057 ERROR [STDERR]     at
org.jboss.ejb.plugins.MessageDrivenTxInterceptorBMT.invoke(MessageDriven
TxInterceptorBMT.java:33)
16:18:19,057 ERROR [STDERR]     at
org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDri
venInstanceInterceptor.java:88)
16:18:19,057 ERROR [STDERR]     at
org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInter
ceptor.java:100)
16:18:19,057 ERROR [STDERR]     at
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
16:18:19,057 ERROR [STDERR]     at
org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryF
inderInterceptor.java:154)
16:18:19,057 ERROR [STDERR]     at
org.jboss.ejb.MessageDrivenContainer.invoke(MessageDrivenContainer.java:
312)
16:18:19,057 ERROR [STDERR]     at
org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker
.java:697)
16:18:19,057 ERROR [STDERR]     at
org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMess
age(JMSContainerInvoker.java:763)
16:18:19,057 ERROR [STDERR]     at
org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:241)
16:18:19,057 ERROR [STDERR]     at
org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessage
Consumer.java:643)
16:18:19,057 ERROR [STDERR]     at
org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:457)
16:18:19,057 ERROR [STDERR]     at
org.jboss.mq.SpySession.run(SpySession.java:309)
16:18:19,057 ERROR [STDERR]     at
org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:177)
16:18:19,057 ERROR [STDERR]     at
EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecuto
r.java:655)
16:18:19,057 ERROR [STDERR]     at java.lang.Thread.run(Thread.java:536)

Thanks for you help,
Emily


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to