Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connection Pooling Problem?

 
Mike London
Ranch Hand
Posts: 1185
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

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!

M
 
Shailesh Kini
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike,

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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic