jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes Connection Pooling Problem? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Connection Pooling Problem?" Watch "Connection Pooling Problem?" New topic

Connection Pooling Problem?

Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1130

I've written a standalone Java application (first) to make sure I could insert a new blob into an Oracle Database via JDBC. That works fine.

There are several steps to doing this including:

1. Doing an insert for the EMPTY_BLOB() (locator)

2. Then doing other stuff in that session, like getting the primary key just entered via the sequence.

The problem is that in our "actual" application, with connection pooling, I can't get the Oracle "currval" once I do the insert (step 1) with the sequence's "nextVal".

The error I get is: "sequence is not yet defined in this session"

Yet, in the standalone Java application it works fine. Same JDBC connection, same database, etc.. The only difference I can determine is the real application has connection pooling.

Any ideas how to resolve this issue? Perhaps I should override the application's DAO methods to use a single connection object for these steps?

I really appreciate them in advance!

Shailesh Kini
Ranch Hand

Joined: Oct 17, 2001
Posts: 153

Are you calling getConnection for each of the steps you mentioned below or just one time before executing all these steps. The difference being, when you call getConnection on your datasource it could return a different instance of connection everytime.

In my opinion the possible resolution for this issue would be to call getConnection once and execute all these steps with that reference and closing it after you are done.

Shailesh Kini.
I agree. Here's the link: http://aspose.com/file-tools
subject: Connection Pooling Problem?
It's not a secret anymore!