This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Websphere and the fly likes connect to oracle through connection pool, DataSource Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Products » Websphere
Reply Bookmark "connect to oracle through connection pool, DataSource" Watch "connect to oracle through connection pool, DataSource" New topic
Author

connect to oracle through connection pool, DataSource

mali djuro
Greenhorn

Joined: Oct 20, 2003
Posts: 3
Hi, all
last few days i tried to make connection on database through connection pool.
the code i used is:
<%
...
String error = null;
try{
error = "Setting property...";
java.util.Properties params = new java.util.Properties();
params.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
error = "Initializing InitialContext...";
javax.naming.Context ctx = new javax.naming.InitialContext(params);
error = "getting DataSource...";
javax.sql.DataSource ds = (javax.sql.DataSource)ctx.lookup("java:comp/env/jdbc/myDS");
error = "getting connection...";
java.sql.Connection conn = ds.getConnection(username, password);
System.out.println("DataSource works!!");
}
catch (Exception e){
System.out.println(error + e);
}
...
%>
i used variable error to detect where is problem.
when i start this application on Websphere server 4.0 i got following exception:
Initializing InitialContext...
javax.naming.NoInitialContextException:
Cannot instantiate class: com.ibm.websphere.naming.WsnInitialContextFactory
[Root exception is java.lang,ClassCastException]
if you have some ideas, or you have sollution,
please help.
thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56549
    
  14

I think you'll get more pertinent response in the Webspere forum, so I'm going to move this topic along there.
bear


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: connect to oracle through connection pool, DataSource
 
Similar Threads
exception when using WAS connection pool
please help!!!!
JNDI lookup....need help
Help: WSAD DataSource Problem
WebSphere Studio v5 & Connection Pooling