Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 20th, 2003, 07:51 AM
Registered User
 
Join Date: Oct 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataSource, Oracle...

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); //here is error
    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






Similar Threads
Thread Thread Starter Forum Replies Last Post
call oracle function using oracle link server vl SQL Server 2000 1 July 12th, 2007 08:19 AM
Object datasource VS DataSource SoftMind BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 4 July 27th, 2006 10:44 PM
How to Read Oracle Data without Oracle being insta badrinarayanang Oracle 1 October 6th, 2005 06:34 AM
How to configure XA-DataSource for Oracle in JBoss keseln J2EE 0 September 24th, 2003 09:42 AM
How to configure XA-DataSource for Oracle in JBoss keseln Wrox Book Feedback 1 September 24th, 2003 09:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.