Bug #87000 com.mysql.jdbc.Driver showing Null pointer Exception for mysqlconnectorjava-5.1
Submitted: 10 Jul 2017 15:30 Modified: 21 Aug 2017 6:22
Reporter: Ganesh Pawar Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:mysql-connector-java-5.1.42 OS:Any
Assigned to: CPU Architecture:Any
Tags: J2EE, mysql-connector-java-5.1.42, SERVLET

[10 Jul 2017 15:30] Ganesh Pawar
Description:

I have created Servlet using Eclipse IDE and Deploy on Tomcat 9 Server.
I am unable to connect to the Database using mysql-connector-java-5.1.42.jar 
I have already added mysql-connector-java-5.1.42.jar to my lib directory.

http://localhost:8080/RegFormGenServlet/reg
Servlet opens but just shows
com.mysql.jdbc.Driver

Code:
package controller;

import java.sql.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.DriverManager;

import javax.servlet.GenericServlet;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebServlet;

import java.sql.Connection;

/**
 * Servlet implementation class RegFormGenericServlet
 */
@WebServlet("/RegFormGenericServlet")
public class RegFormGenericServlet extends GenericServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see GenericServlet#GenericServlet()
     */
    public RegFormGenericServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see Servlet#service(ServletRequest request, ServletResponse response)
	 */
	public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
		
		PrintWriter out=response.getWriter();
		response.setContentType("text/html");
		
		int id1=Integer.parseInt(request.getParameter("id"));
		String name=request.getParameter("name");
		String email=request.getParameter("email");
		String address=request.getParameter("address");
		try{
			Class.forName("com.mysql.jdbc.Driver");
			Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/student","root", "ganesh");
			String query="insert into student values (?,?,?,?)";
			PreparedStatement pst=con.prepareStatement(query);
			pst.setInt(1, id1);
			pst.setString(2, name);
			pst.setString(3, email);
			pst.setString(4, address);
			int i=pst.executeUpdate();
			
			
			if(i!=0)
			{
				out.println("<font color='green'><h1>Register Successfully</h1></font>");
			}
			else
			{
				out.println("<font color='red'><h1>Register Failed</h1></font>");
			}
		}
		catch(Exception e)
		{
			out.println("<font color='green'><h1>"+e.getMessage()+"</h1></font>");
		}
	}

}

How to repeat:

I have created Servlet using Eclipse IDE and Deploy on Tomcat 9 Server.
I am unable to connect to the Database using mysql-connector-java-5.1.42.jar 
I have already added mysql-connector-java-5.1.42.jar to my lib directory.

http://localhost:8080/RegFormGenServlet/reg
Servlet opens but just shows
com.mysql.jdbc.Driver

I have search on net but no option found to fix this issue.
[19 Jul 2017 12:41] Chiranjeevi Battula
Hello  Ganesh,

Thank you for the bug report.
Could you please provide us tomcat logs (- please make it as private if you prefer) to confirm this issue at our end?

Thanks,
Chiranjeevi.
[20 Aug 2017 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[20 Aug 2017 9:11] Ganesh Pawar
Thanks for helping me
I have fix the problem.
Thanks again for helping me.
[21 Aug 2017 6:22] Chiranjeevi Battula
Hello  Ganesh,

Thank you for your feedback.
I'm glad that you found a solution for your problem and let us know if you are still having the issue with complete repeatable steps.

Thank you for your interest in MySQL.

Thanks,
Chiranjeevi.