0

I have added the mysql-connector-java-5.1.19.jar but i don't know why the error is coming. driver is imported as shown in the image

    public class data {
    String server = "jdbc:mysql://localhost/";
    String user = "root";
    String pass = "toor";
    public int starting() {
        int id;
        try {
            Class.forName("com.mysql.jdbc.driver");
            Connection incre = (Connection) DriverManager.getConnection("inc"+server, user, pass);
            Statement statement = (Statement) incre.createStatement();
            String select = "Select start from incr;";
            ResultSet rs = (ResultSet) statement.executeQuery(select);
            if(rs.next()){
                id = rs.getInt("start");
            }
            incre.close();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
}
1
  • not sure but driver should be Driver Commented Apr 16, 2016 at 15:37

1 Answer 1

2

Java is case sensitive, instead of com.mysql.jdbc.driver you need

Class.forName("com.mysql.jdbc.Driver");

However, with modern JDBC drivers this line is not required at all, so I would try removing it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.