5 Replies Latest reply on Jun 20, 2003 4:55 PM by iariel

    trying to return unknown connection

    theone Newbie

      i am running an application on jboss3.0.7 and Ingres. I get the connections from a "localtxds" and do my db operations.
      However whjen i try to close the connection (con.close()), my server throws an error saying "trying to return unknown connection..blah blah.. ". Any solutions.
      thanks in advance.


        • 1. Re: trying to return unknown connection
          eduz Newbie

          Hi, i have the same problem, i'm using JBoss 3.2.1 and PostgreSQL 7.3.2, i have some CMP beans, they work flawlessly, but when I try to get a connection in a Session bean I get the same error.

          my postgres-ds.xml:


          my code:
          Connection con = ( (DataSource)new InitialContext().lookup("java:/PostgreSQL") ).getConnection();
          stmt = con.createStatement();
          rs = stmt.executeQuery("select nextval(\'"+sequenceName+"\')");

          the goddamn exception:
          java.lang.IllegalStateException: Trying to return an unknown connection1!

          org.jboss.resource.adapter.jdbc.WrappedConnection@13b64eb at org.jboss.resource.connectionmanager.CachedConnectionManager.unregisterConnection(CachedConnectionManager.java:264) at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.connectionClosed(TxConnectionManager.java:550)

          Please, I need some help! :)
          Thanks in advance,

          • 2. Re: trying to return unknown connection
            Ricardo Coutinho Newbie

            The only time I got these errors was when I was trying to open a connection before closing existing ones. As soon as I fixed that, the errors went away.

            My guess is that maybe one the entity beans is still busy using the datasource while you are asking to for another connection.

            I am using Jboss 3.0.7

            • 3. Re: trying to return unknown connection
              eduz Newbie

              IT WORKED!
              Thanks a lot!!


              • 4. Re: trying to return unknown connection
                marweb Newbie

                I got the same exception "Trying to return unknown connection1" and found a way to prevent it.

                I'm using JBoss 3.2.1 with MySQL on windows. I implemented the DAC pattern as published by Floyd Marinescu (using a stateful session bean which uses JDBC).

                My first version looked like this (in the original version Floyd used preparedStatements of course):

                public abstract class BaseUpdateCommand
                protected Statement stmt;
                private Connection con;
                protected BaseUpdateCommand (String jndiName)
                throws DataCommandException
                ctx = new InitialContext ();

                ds = (javax.sql.DataSource)ctx.lookup (jndiDSName);

                con = ds.getConnection ();

                stmt = con.createStatement ();

                public long execute (String statement)
                throws DataCommandException
                updateCount = stmt.executeUpdate (statement);

                This code has always thrown exceptions - even when used in a single-threaded test scenario. Only when I moved the createStatement and the getConnection statements into the execute-method all exceptions vanished.

                Now I'm mystified - any idea what happened ?

                • 5. Re: trying to return unknown connection
                  iariel Newbie

                  I am pissed off, I have the same problem. I spent hours to find out that this is a JBOSS issue as you all suggesated. Is this how JBOSS makes money. Charging support to fix their problem. I am discussed.