package SeleWeb;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.sql.*;

 public class seldata 


   public static void main(String[] args) throws Exception 


   Connection connection;
   Statement statement;
   ResultSet rs;

   WebDriver driver = new FirefoxDriver();
   String dbaseURL = "http://localhost:3306/selenium";
   String user = "root";
   String password = "";
   connection = null;
   try {    
           System.out.println("Connecting to Database...");
           connection = DriverManager.getConnection(dbaseURL, user, password);

           //connection = DriverManager.getConnection("dbaseURL","root","");
           if (connection != null) 
                System.out.println("Connected to the Database...");
                try {
                        String query = "select * from employee";
                        statement = connection.createStatement();
                        rs = statement.executeQuery(query);

                            int EmpId= rs.getInt("EmpId");
                            String EmpName= rs.getString("EmpName");
                            String EmpAddress=rs.getString(3);
                            String EmpDept=rs.getString("EmpDept");
                            Double EmpSal= rs.getDouble(5);
                    } catch (SQLException ex) 

            }catch (SQLException ex) 


  • Which JARs you have imported to project for database connection? Dec 31, 2015 at 11:27
  • mysql-connector-java-5.0.8-bin.jar
    – PRasd
    Dec 31, 2015 at 11:28
  • Can you please use latest JAR from here : code.google.com/p/find-ur-pal/downloads/… Dec 31, 2015 at 11:31
  • not worked, same error reproduces
    – PRasd
    Dec 31, 2015 at 11:33
  • You need to check if your jar matches with the mysql(variant) you are trying to connect with. Dec 31, 2015 at 13:35

1 Answer 1


Usually this exception occurs when the JDBC URL is wrong and not accepted by loaded drivers. You should have the jar files in the classpath. Also Try using JDBC driver specific URI prefix, which is jdbc:mysql:// for MySQL. I mean defining

String dbaseURL = "jdbc:mysql://localhost:3306/selenium";

instead of

String dbaseURL = "http://localhost:3306/selenium";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.