0

I am trying to connect to mysql database. I am using MySQL workbench. These are my codes:

 Class.forName("com.mysql.jdbc.Driver");
 con =DriverManager.getConnection("jdbc:mysql://localhost/try?" +"user=jenny&password=perez");

 PreparedStatement ps=con.prepareStatement("SELECT * FROM address");
 ResultSet myRS=ps.executeQuery();

What's wrong with my codes?

Chrismas007
  • 6,085
  • 4
  • 24
  • 47

1 Answers1

1

Your codes are correct. You come up with that error because you have no mysql connector. Try to download mysql-connector-java-5.1.18-bin. Install it here C:\Program Files\Java\jre6\lib. Then, Go to the properties of your project, then follow these:

Go to Libraries, then Compile, click Add JAR/Folder, then search the mysql connector you installed. Then run your program. ^_^

Rachelle Tud
  • 215
  • 1
  • 10