Could not find or load main Class on JAR executing

后端 未结 2 1068
长情又很酷
长情又很酷 2020-12-10 20:15

I finished my project (in NetBeans) and i export Jar file (i set my main class in project properties correctly before exporting Jar):<

2条回答
  •  时光说笑
    2020-12-10 20:24

    So,here comes an error to the problem---why have you mentioned con = DriverManager.getConnection(...); in your code?

    And hence your code is catching SQL Exception!!! This is the source of error :-

    public boolean userEnterCondition(char[] pass) {
    Connection con;
    PreparedStatement preparedStatement;
    ResultSet resultSet;
    String query = "Select * from users";
    String password = null;
    try {
        Class.forName("com.mysql.jdbc.Driver");
        con = DriverManager.getConnection(...);     //error in this line
    
    ................. and so on.
    

    Replace it with

    con =DriverManager.getConnection("jdbc:mysql://localhost/Library?" +
                                   "user=yourusername&password=yourpassword");
    

    I hope this helps.If still getting error,please comment below!

提交回复
热议问题