Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAVA JDBC connectivity problem. Kindly see the attached code, Please guide me.

 
vicky amrev
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JAVA JDBC connectivity problem. I am using MySql database, also I have downloaded and configure JDBC Connector. In the end of this code please see the error that I am getting.
 
sonu raj
Ranch Hand
Posts: 43
Android C++ Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hi vicky,
I copied your code and created a database according to your code and I found two errors.
You have written "com.mysql.Jdbc.Driver". here 'J' of Jdbc should be in lowercase it should be "com.mysql.jdbc.Driver"
vicky amrev wrote:
try{
Class.forName("com.mysql.Jdbc.Driver");


one more mistake you have not mentioned any user name and password in below code, do mention the username and password for your mysql.

conn = DriverManager.getConnection(
"jdbc:mysql://vicky-PC/student");
rs = conn.createStatement().executeQuery("select * from student");


It should be DriverManager.getConnection("jdbc:mysql://vicky-PC/student","root","password"); here root is default username for mysql and enter the password set while installing it.
Rest of the code is Correct. All the best!!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic