473,402 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

JSP, DataSource, Oracle...

Hi all,
i try to connect to the Oracle database through the DataSource, here is code
that i used

<%
....
String error = new String();
try {
java.util.Properties parms = new java.util.Properties();

error = "Defining Initial Context Factory...";
parms.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.ejs.ns.jndi.CNInitialContextFactory") ;

error = " Defining Provider...";
parms.setProperty(Context.PROVIDER_URL, "iiop:///");

error = "Initializing InitialContext...";
ctx = new javax.naming.InitialContext(parms);

error = "Get DataSource from InitialContext...";
ds = (javax.sql.DataSource)ctx.lookup(ds_conn_string);

error = "Get Connection...";
con = ds.getConnection(ds_user, ds_password);

System.out.println("Datasource works!");

}
catch (Exception ne) {
System.out.println(error + "\n" + ne);
}
...
%>

When i start application on the server and try to access to the
database i got message in server log

Initializinig Initial Context...
Cannot instantiate class: com.ibm.ejs.ns.jndi.CNInitialContextFactory
[Root exception is java.lang.ClassCastException]

i tried also with com.ibm.websphere.naming.WsnInitialContextFactory
because i found that com.ibm.ejs.ns.jndi.CNInitialContextFactory
is deprecated, but i got same message

Initializinig Initial Context...
Cannot instantiate class: com.ibm.websphere.naming.WsnInitialContextFactory
[Root exception is java.lang.ClassCastException]

i found so much examples on the web, that says it has to works
but i cannot do it.
is it possible that i have to set some special properties on my server?
is it something wrong in my code?

please help.
thanks in advance.


Jul 17 '05 #1
1 6481
i forgot to say i work in JSP
Hi all,
i try to connect to the Oracle database through the DataSource, here is code
that i used

<%
...
String error = new String();
try {
java.util.Properties parms = new java.util.Properties();

error = "Defining Initial Context Factory...";
parms.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.ejs.ns.jndi.CNInitialContextFactory") ;

error = " Defining Provider...";
parms.setProperty(Context.PROVIDER_URL, "iiop:///");

error = "Initializing InitialContext...";
ctx = new javax.naming.InitialContext(parms);

error = "Get DataSource from InitialContext...";
ds = (javax.sql.DataSource)ctx.lookup(ds_conn_string);

error = "Get Connection...";
con = ds.getConnection(ds_user, ds_password);

System.out.println("Datasource works!");

}
catch (Exception ne) {
System.out.println(error + "\n" + ne);
}
..
%>

When i start application on the server and try to access to the
database i got message in server log

Initializinig Initial Context...
Cannot instantiate class: com.ibm.ejs.ns.jndi.CNInitialContextFactory
[Root exception is java.lang.ClassCastException]

i tried also with com.ibm.websphere.naming.WsnInitialContextFactory
because i found that com.ibm.ejs.ns.jndi.CNInitialContextFactory
is deprecated, but i got same message

Initializinig Initial Context...
Cannot instantiate class: com.ibm.websphere.naming.WsnInitialContextFactory
[Root exception is java.lang.ClassCastException]

i found so much examples on the web, that says it has to works
but i cannot do it.
is it possible that i have to set some special properties on my server?
is it something wrong in my code?

please help.
thanks in advance.

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jan Bols | last post by:
I've been trying to install Oracle 8.1.7 on a fresh Mandrake 9.1 O.S for days, but I'm still not able to get it running. I've tried several install instructions that I found on the internet but no...
3
by: lee_mcknight | last post by:
I am using Crystal Enterprise V9. I have a report that needs to have multiple datasets as the datasource(s) on a single subreport (some common lookup data I need to join to is stored in a seperate...
13
by: Chris Botha | last post by:
The machine is running XP Pro with all the latest service packs, etc. I must access an Oracle database so I installed the Oracle client stuff. I can query Oracle from a Windows app, no problem....
7
by: George | last post by:
Hi, Does anyone know how to bind text file to a datasource (of a combobox in my case)? I went through the properties, but it seems like the only "boundable" sources are databases such as...
2
by: Werner Sammer | last post by:
I tried to connect to an existing Oracle Database with the following ConnectionString: using System.Data.OracleClient; // + Added Reference "System.Data.OracleClient" string cs = "Data...
2
by: Vinod Sadanandan | last post by:
All, Below listed are the new features in Oracle 11g ,please join me in this discussion to generate a testcase and analyze each of the listed features . Precompilers:...
2
by: Ruslan A Dautkhanov | last post by:
Hello ! I'm about to install O9i on FreeBSD box. uname -a: FreeBSD stat2.scn.ru 5.2.1-RELEASE-p3 FreeBSD 5.2.1-RELEASE-p3 #2: Fri Apr 23 19:19:43 KRAST 2004...
0
by: Jack | last post by:
Training Classes for Oracle10g, 9i, 8i Certification training in Oracle10g and 9i: DBA, Developer, Discoverer. training conducted at your location worldwide. Courseware licensing also available....
0
by: Winder | last post by:
Training Classes for Oracle10g, 9i, 8i Certification training in Oracle10g and 9i: DBA, Developer, Discoverer. training conducted at your location worldwide. Courseware licensing also available....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.