File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes datasource jndi cast error. help! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "datasource jndi cast error. help!" Watch "datasource jndi cast error. help!" New topic
Author

datasource jndi cast error. help!

Joseph Siao
Ranch Hand

Joined: Feb 26, 2004
Posts: 32
I need help. I am using websphere 5, and MySQL as my database. I created a datasource in my websphere server test environment. I create a simple java application to lookup the datasource.
Here is my code :
public static void main(String arg[]){
try{
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("jdbc/ds1");
System.out.println("Finished");
}catch(Exception e){
e.printStackTrace();
}
}
An error is occuring on DataSource cast. I dont know why..
Here is the error :
java.lang.ClassCastException: javax.naming.Reference
at ds.test.DsTestMain.main(DsTestMain.java:37)
Hope someone can help me.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60049
    
  65

"ajsc",
We're pleased to have you here with us in the JDBC forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.
In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.
Thanks!
bear
Forum Bartender
[ April 14, 2004: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Joseph Siao
Ranch Hand

Joined: Feb 26, 2004
Posts: 32
Sorry about that. I didnt know. I have changed it already. Oh, the ajsc was my initials.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: datasource jndi cast error. help!
 
Similar Threads
Not able to perform JNDI lookup in my servlet
Problem with DataSource
JNDI Lookup help in websphere 4.0
datasource jndi cast error
Not able to perform JNDI lookup