0

I've been getting an error saying Http error 500 internal server error, I've created a table like this

CREATE TABLE `EMPLOYEE` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `FIRST_NAME` varchar(45) NOT NULL,
  `LAST_NAME` varchar(45) NOT NULL,
  `EMAIL` varchar(45) NOT NULL,
  `USER_NAME` varchar(45) NOT NULL,
  `PASSWORD` varchar(45) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Except for the fact that I typed the employee table name in small letters.

The program is in the link below a dynamic web project ! [http://www.javawebtutor.com/code/jsp/LoginExample.zip][1]

Class.forName("com.mysql.jdbc.Driver");  
Connection con=DriverManager.getConnection(  
"jdbc:mysql://localhost:3306/sonoo","root","root");  

is it because I've missed typing this line

THE CODE

    <%@page import="java.sql.Statement"%>
    <%@page import="java.sql.Connection"%>
    <%@page import="com.example.util.DBUtil"%>
    <%
        String userName = request.getParameter("username");
        String password = request.getParameter("password");
        String firstName = request.getParameter("firstname");
        String lastName = request.getParameter("lastname");
        String email = request.getParameter("email");
        Connection con = DBUtil.getMySqlConnection();
        Statement st = con.createStatement();
        //ResultSet rs;
        int i = st
                .executeUpdate("insert into EMPLOYEE(FIRST_NAME, LAST_NAME, EMAIL, USER_NAME, PASSWORD) values ('"
                        + firstName
                        + "','"
                        + lastName
                        + "','"
                        + email
                        + "','" 
                        + userName
                        + "','" 
                        + password 
                        + "')");
        if (i > 0) {
            response.sendRedirect("welcome.jsp");
        } else {
            response.sendRedirect("index.jsp");
        }
    %>






**THE ERROR I GET**


org.apache.jasper.JasperException: An exception occurred processing [/registration.jsp] at line [10]

7:  String firstName = request.getParameter("firstname");enter code here
8:  String lastName = request.getParameter("lastname");
9:  String email = request.getParameter("email");
10:     Connection con = DBUtil.getMySqlConnection();
11:     Statement st = con.createStatement();
12:     //ResultSet rs;
13:     int i = st


Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:618)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:500)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)


Root Cause 
javax.servlet.ServletException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Client does not support authentication protocol requested by server; consider upgrading MySQL client
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:917)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:846)
    org.apache.jsp.registration_jsp._jspService(registration_jsp.java:126)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)


Root Cause 

    com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Client does not support authentication protocol requested by server; consider upgrading MySQL client
        sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        java.lang.reflect.Constructor.newInstance(Unknown Source)
        com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
        com.mysql.jdbc.Util.getInstance(Util.java:384)
        com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)
        com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566)
        com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498)
        com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:919)
        com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4004)
        com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1284)
        com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2312)
        com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2122)
        com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:774)
        com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49)
        sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        java.lang.reflect.Constructor.newInstance(Unknown Source)
        com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
        com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:375)
        com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:289)
        java.sql.DriverManager.getConnection(Unknown Source)
        java.sql.DriverManager.getConnection(Unknown Source)
        com.example.util.DBUtil.getMySqlConnection(DBUtil.java:10)
        org.apache.jsp.registration_jsp._jspService(registration_jsp.java:94)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
        org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)


Note The full stack trace of the root cause is available in the server logs.


  [1]: http://www.javawebtutor.com/code/jsp/LoginExample.zip
  [2]: https://i.stack.imgur.com/XcLfl.png
FanoFN
  • 6,815
  • 2
  • 13
  • 33
Philomath
  • 1
  • 1
  • It seems there is version issue. Please refer the below link: https://stackoverflow.com/questions/50505042/mysqlnontransientconnectionexception-client-does-not-support-authentication-pro – ARPAN CHAKARVARTY Jan 07 '20 at 09:34
  • Do you have some more information on the server error? Somewhere in the logs should be a stracktrace with some MySQL references. Also, beware that your JSP is not closing the statement + connection, you'll eventually run into trouble with that. – Simon Jan 07 '20 at 09:48
  • After updating the jdbc connector jar file in par with the mysql version this is the error i received HTTP Status 500 – Internal Server Error Type Exception ReportMessage javax.servlet.ServletException: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) Description The server encountered an unexpected condition that prevented it from fulfilling the request. Exception org.apache.jasper.JasperException: javax.servlet.ServletException: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) – Philomath Jan 07 '20 at 09:52
  • Connection con=DriverManager.getConnection( "jdbc:mysql://localhost:3306/sonoo","root","root"); in this line could you plese check your mysql password... – BalaMurugan.N Mar 09 '20 at 13:14

0 Answers0