I am new to Java world, while creating a webapp using NetBeans code is working fine till get method is executed but when I am trying to execute the SQL query glassfish is unable to show data from MSQL DB and giving errors. I am using
- Apache NetBeans IDE 18
- JDK20
- Glassfish 7.0.3
- MySQL 8.0 CE
- windows10
In my project created a servlet called GreetingServlet.java which should get executed to fetch data from library database. library is running. But my code is showing errors in web browser like
HTTP Status 500 - Internal Server Error
type Exception report
messageInternal Server Error
descriptionThe server encountered an internal error that prevented it from fulfilling this request.
exception
jakarta.servlet.ServletException: Servlet Could not display records.
root cause
java.sql.SQLNonTransientConnectionException: Cannot open file:C:\Users\Subhranshu\glassfish7\glassfish\domains\domain1/config/keystore.jks [Keystore was tampered with, or password was incorrect]
root cause
com.mysql.cj.exceptions.SSLParamsException: Cannot open file:C:\Users\Subhranshu\glassfish7\glassfish\domains\domain1/config/keystore.jks [Keystore was tampered with, or password was incorrect]
root cause
java.io.IOException: Keystore was tampered with, or password was incorrect
root cause
java.security.UnrecoverableKeyException: Password verification failed
Please find my code:
Connection con;
con = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
Class.forName("com.mysql.cj.jdbc.Driver");
con =DriverManager.getConnection
//("jdbc:mysql://127.0.0.1:3306/library","root","");
("jdbc:mysql://localhost:3306/library","root","");
stmt = con.prepareStatement("select * from users where username = ? and password = ?");
stmt.setString(1, username);
stmt.setString(2, password);
rs = stmt.executeQuery();