I finished my project (in NetBeans
) and i export Jar
file (i set my main class in project properties correctly before exporting Jar
):<
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!
Open your jar file with WinRAR or a similar program. Then go to the META-INF folder and open the MANIFEST.MF. Make sure the property "Main-Class: your.class.path" is correct.