• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

datasource jndi cast error. help!

 
Joseph Siao
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65125
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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 ]
 
Joseph Siao
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about that. I didnt know. I have changed it already. Oh, the ajsc was my initials.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic