-
1. Re: trying to return unknown connection
eduz May 26, 2003 11:07 AM (in response to theone)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:
<local-tx-datasource>
<jndi-name>PostgresDS</jndi-name>
<connection-url>jdbc:postgresql://bdffs12:5432/brisa</connection-url>
<driver-class>org.postgresql.Driver</driver-class>
<user-name>dbcomut</user-name>
dbcomut
</local-tx-datasource>
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,
Eduardo. -
2. Re: trying to return unknown connection
rixc May 26, 2003 12:37 PM (in response to theone)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 May 26, 2003 1:42 PM (in response to theone)IT WORKED!
Thanks a lot!!
Regards,
Eduardo -
4. Re: trying to return unknown connection
marweb May 28, 2003 4:03 AM (in response to theone)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 Jun 20, 2003 4:55 PM (in response to theone)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.