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 Unable to Access mysql database through JNDI. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Unable to Access mysql database through JNDI." Watch "Unable to Access mysql database through JNDI." New topic
Author

Unable to Access mysql database through JNDI.

Vishal Srivastav
Ranch Hand

Joined: Nov 29, 2008
Posts: 46

Dear Friends,

I am trying to access mysql database through JNDI but I am not able to access it. I am not much familiar to JNDI. I am sending you the coding part of my programs. Kindly help me and tell where am I making a mistake -

DatabaseCheck.java



Student.java



When I used simple statement

java DatabaseCheck

to run the code, following error message flashed -



I later used the following command for running the application -

java -Djava.naming.factory.initial=com.mysql.jdbc.Driver -Djava.naming.provider.url=jdbc:mysql://localhost:3306/studentDB DatabaseCheck

Then following error msg flashed -



The user of mysql is root and password is mysql@123. Is there something extra needed to be done.

Please tell where I am commiting mistake? Suggestions are welcomed.

Waiting for your response friends.

Regards,
VIshal.


Vishal Srivastava, Software Engineer (Android), Paradigm Creatives
SCJP 5, SCWCD 5 - http://in.linkedin.com/in/srivastavavishal
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6662
    
    5

-Djava.naming.factory.initial=com.mysql.jdbc.Driver -Djava.naming.provider.url=jdbc:mysql://localhost:3306/studentDB


These are supposed to be JNDI related implementation details. They do not have anything to do with JDBC, thus the class cast exception.

Change the factory and procider URL to reflect the right values


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Syed Saifuddin
Ranch Hand

Joined: Sep 01, 2003
Posts: 130
Check your config file also. config file of server.


Thank You & Best Regards,

Syed Saifuddin,
Senior Software Engineer

SAP Oracle AIX & Java Training
http://www.socialinet.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to Access mysql database through JNDI.