• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Unable to Access mysql database through JNDI.

 
Ranch Hand
Posts: 48
1
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

-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
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check your config file also. config file of server.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic