You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Propes, Barry L [GCG-NAOT]" <ba...@citigroup.com> on 2007/02/19 19:22:01 UTC
Connection pool problem DBCP - 4.1.3
This is driving me crazy. I'm finally close, I think, on getting this solved.
Problem is I seem to either get Connection is closed or Exhausted resultset, depending where I put my close statement.
I've got the following up at the top, which replaces my driver reference that was previously there.
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
// Look up our data source
DataSource ds = (DataSource)
envCtx.lookup("jdbc/myoracle");
// Allocate and use a connection from the pool
Connection connection = ds.getConnection();
Statement selstmt = connection.createStatement();
String prepSQL = "SELECT AID, ACTIVE, REQUESTOR_NAME...," +
"PHONE_NUM,DATE_REQ,... " +
"...." +
"FROM table a INNER JOIN table b " +
"ON a.CTRL_ID = b.CTRL_ID " +
"WHERE AID = ?";
PreparedStatement prepstmt = connection.prepareStatement(prepSQL);
prepstmt.setString(1, aidstrd);
ResultSet admsql = prepstmt.executeQuery();
admsql.next();
(etc., etc.)
admsql.close();
selstmt.close();
connection.close();
If I move up connection.close, I get the Connection is closed statement, otherwise I get exhausted result set.
Any idea what gives?
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Connection pool problem DBCP - 4.1.3
Posted by -- <jo...@fastwebnet.it>.
I think you should also call
prepstmt.close()
(before closing the connection).
Besides
selstmt
seems not to be used at all.
Bye
> This is driving me crazy. I'm finally close, I think, on getting this solved.
>
> Problem is I seem to either get Connection is closed or Exhausted resultset, depending where I put my close statement.
>
>
> I've got the following up at the top, which replaces my driver reference that was previously there.
>
> Context initCtx = new InitialContext();
> Context envCtx = (Context) initCtx.lookup("java:comp/env");
> // Look up our data source
> DataSource ds = (DataSource)
> envCtx.lookup("jdbc/myoracle");
> // Allocate and use a connection from the pool
> Connection connection = ds.getConnection();
>
> Statement selstmt = connection.createStatement();
>
> String prepSQL = "SELECT AID, ACTIVE, REQUESTOR_NAME...," +
> "PHONE_NUM,DATE_REQ,... " +
> "...." +
> "FROM table a INNER JOIN table b " +
> "ON a.CTRL_ID = b.CTRL_ID " +
> "WHERE AID = ?";
>
> PreparedStatement prepstmt = connection.prepareStatement(prepSQL);
> prepstmt.setString(1, aidstrd);
> ResultSet admsql = prepstmt.executeQuery();
> admsql.next();
>
> (etc., etc.)
>
> admsql.close();
> selstmt.close();
> connection.close();
>
> If I move up connection.close, I get the Connection is closed statement, otherwise I get exhausted result set.
> Any idea what gives?
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org