-1

My code is as follows

import java.sql.*;


public class jbdcTrial {

    public static void main(String[] args) throws Exception{
        String dburl ="jdbc:mysql://localhost:3306/users";
        String username ="root";
        String password ="Calvin25;";


        try {

            Class.forName("com.mysql.jdbc.Driver");
            Connection myconnection = DriverManager.getConnection(dburl,username,password);


            Statement myStatement = myconnection.createStatement();


            ResultSet myresultset = myStatement.executeQuery("select * from employees");

            while(myresultset.next()) {
                 int count =myresultset.getInt(1);
                 System.out.println("count of stock : " + count);

            }
        } catch (SQLException e) {


        }

    }
}

I have mysql connector added in eclipse as a jar library the only output i see is this

Tue Feb 27 17:44:23 EAT 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

But in the tutorial it displays output from the database plus that warning

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373

1 Answers1

-1

Try this:

String dburl ="jdbc:mysql://localhost:3306/users?useSSL=false";
aglassman
  • 2,643
  • 1
  • 17
  • 30