2
votes

I have written a web service using JAX-WS in GlassFish. I get database connection from datasource and pass it to jOOQ.

Context context = new InitialContext();
DataSource dataSource = (DataSource) context.lookup("jdbc/datasrc");
Connection connection = dataSource.getConnection();
DSLContext create = DSL.using(connection, SQLDialect.MYSQL);

At the end of request(based on this question), I close connections with Apache DBUtils:

DbUtils.closeQuietly(connection);

The problem is I can only send one request. After that I get connection closed exception. Connection pool in GlassFish is configured with:

Transaction Isolation: read-commited
Isolation Level:  Guaranteed 
Resource Type: javax.sql.ConnectionPoolDataSource
Datasource Classname: com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource

Am I closing physical connection? I'm using MySQL 5.5.32 on fedora 19 with GlassFish 4 build 89. Can anyone help?

[UPDATE]

I have downgraded to GlassFish 3.1.2.2 and the same code works just fine. Does connection pool behaviour changed in GlassFish 4?

1
If you close the connection at the end of the request, of course you will get an exception if you keep using it afterwards. Solution: don't close it, or get yourself a new one for the subsequent request(s). - user207421
Nothing has changed. If you close the connection after the first request and try to reuse it for another request, you will get this exception. If that isn't what you're doing, you need to clarify your question, because that's what it says as presently stated. - user207421

1 Answers

0
votes

I believe this might be a bug in the release. You might want to report this https://java.net/jira/browse/GLASSFISH