I am using MySQL using the --skip-networking option on Linux.
Trying to connect my J2EE based application (using servlets) to the MySQL database using JDBC.
When was using MySQL with the --skip-networking option disabled, I was connecting to the database as:
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydatabase","myuser","mypassword");
After having enabled the --skip-networking option, I am trying to connect it as:
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/mydatabase","myuser","mypassword");
But this does not seem to work, and I get java.lang.NullPointerException when I try to connect to the database in my application.
After commenting out the --skip-networking option and using the old JDBC statement, I can connect to the database.
Note - I am able to connect to the database via the command line mysql client with the --skip-networking option enabled.
Can anyone tell me how to connect to the database from JDBC? I tried searching for it but could not any satisfactory answer that worked. Thanks in advance.