Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Oracle connection problem with multple datasources

843841Oct 4 2004 — edited Oct 15 2004
Seeing strange oracle connection problems, when using multiple data sources and
on of the datasource initialized during app server startup ( in serverlet init method )

I have servlet with load-on-start flag ON and oracle connection of one the data sources being done in servlet init method. This succeeds.

public void init() throws ServletException {
super.init();
..
..
conn1 = datasource1.getConnection() // works
..
..
conn1.close();
}



But when trying to get connection for a second datasource in doGet() or any where else, it fails with ORA-12154 (TNS:could not resolve service name) error). However getConnection to first data source succeeds.

public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
conn2 = datasource2.getConnection() // fails with ORA-12154
..
..
conn2.close();
..
..

conn1 = datasource1.getConnection() // works
..
..
conn1.close();
}
Also to be noted is that all works fine if load-on startup flag for the servlet is turned OFF.

Appreciate any help in this regards, am using Websphere 5.1 app server
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 12 2004
Added on Oct 4 2004
19 comments
362 views