I am a beginner in using Eclipse. I am using Eclipse LUNA package and MySQL 6.0 Workbench. I have pasted "mysql-connector-java-5.0.8-bin.jar" file in Referenced Library file. My coding is as follows:
package a1;
import java.util.Scanner;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
class a2 {
public static void main (String[] args) {
String dbURL = "jdbc:mysql://localhost:3306/test";
String username ="root";
String password = "root";
Connection dbCon = null;
Statement stmt = null;
ResultSet rs = null;
String query ="select * from k111";
try {
dbCon = DriverManager.getConnection(dbURL, username, password);
stmt = dbCon.prepareStatement(query);
rs = stmt.executeQuery(query);
System.out.println("Success");
while(rs.next()){
System.out.println(query);
}
}
catch(SQLException ex)
{
System.out.println(ex);
}
finally
{
rs.close();stmt.close(); dbCon.close();
}
}}
My database name is "test". My table name is k111. I just need to print "Success" as per the program to know whether the database connectivity is successful or not. But, my output is
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/test
Kindly guide me.......