Bug #2947 Problem in using Connector/J 3.0.10 with MySQL 4.0.17
Submitted: 24 Feb 2004 19:14 Modified: 28 Mar 2014 10:22
Reporter: Tun Yee Lui Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / J Severity:S1 (Critical)
Version:3.0.10 OS:HP/UX (HP ES45 True64 5.1a)
Assigned to: Alexander Soklakov CPU Architecture:Any

[24 Feb 2004 19:14] Tun Yee Lui
Description:
I tried to connect to a MySQL 4.0.1.7 database using MySQL Connector/J v.3.0.10
and the following error appears.  However, if I use the same java program with
Connector/J v.2.0.14, the database connection is OK. The MySQL database
is installed at a HP ES45 True64 5.1a.

Newton Lui
=======================================================================
java.sql.SQLException: Unable to connect to any hosts due to exception: java.lang.NullPointerException
        at java.lang.Throwable.fillInStackTrace(Native Method)
        at java.lang.Throwable.fillInStackTrace(Compiled Code)
        at java.lang.Throwable.<init>(Compiled Code)
        at java.lang.Exception.<init>(Exception.java:42)
        at java.sql.SQLException.<init>(SQLException.java:64)
        at com.mysql.jdbc.Connection.createNewIO(Compiled Code)
        at com.mysql.jdbc.Connection.<init>(Connection.java:427)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
:395)
        at java.sql.DriverManager.getConnection(Compiled Code)
        at java.sql.DriverManager.getConnection(DriverManager.java:137)
        at testinsert_mysql.main(Compiled Code)

How to repeat:
Pls try the following program:

import java.sql .* ;
import java.sql.Types.*;
import java.io.*;
import java.util.*;
import java.sql.*;
import java.sql.Types.*;
import java.net.*;

  public static void main(String args[])
  {
   try {
        String k = "t";
        int i = 0;
        while (i < 100) {
        k = k + "t";
          i = i + 1;}
        Connection c = null;
            PreparedStatement s;
        Class.forName("com.mysql.jdbc.Driver");
        c = DriverManager.getConnectio("jdbc:mysql://<hostname>:3306/<database name>", <accountname>, <password>);
        c.setAutoCommit(false);
       String sql3 = "INSERT INTO temp (test) values " + "(?)";
            s = c.prepareStatement(sql3);
            s.setString(1, k);
            s.executeUpdate();
             s.close();
            c.commit();
   }
    catch (Exception ex) {
      ex.printStackTrace();
    }
   }
}
[5 Mar 2004 14:19] Mark Matthews
I can't repeat this.

Can you turn off your JIT so that the line numbers show up in the stack trace?
[8 Mar 2004 18:35] Tun Yee Lui
Sorry, I can't turn off the JIT. I am using java compiler v1.2.2.
[8 Mar 2004 19:41] Mark Matthews
The JIT in JDK-1.2 is disable by exporting the environment variable JAVA_COMPILER with the value 'none'.
[10 Mar 2004 17:51] Tun Yee Lui
After setting JAVA_COMPILER to none, the following is the output:

java.sql.SQLException: Unable to connect to any hosts due to exception: java.lang.NullPointerException
        at java.lang.Throwable.fillInStackTrace(Native Method)
        at java.lang.Throwable.<init>(Throwable.java:94)
        at java.lang.Exception.<init>(Exception.java:42)
        at java.sql.SQLException.<init>(SQLException.java:64)
        at com.mysql.jdbc.Connection.createNewIO(Connection.java:1690)
        at com.mysql.jdbc.Connection.<init>(Connection.java:427)
        at com.mysql.jdbc.NonRegisteringDriver.connec(NonRegisteringDriver.java:395)
        at java.sql.DriverManager.getConnection(DriverManager.java:457)
        at java.sql.DriverManager.getConnection(DriverManager.java:137)
        at testinsert_mysql.main(testinsert_mysql.java:32)
[10 Mar 2004 18:49] Mark Matthews
Your stack trace is pointing to code that is in a catch{} block.

You can either start a debugger and see where the actual NPE is happening, or you can try upgrading to 3.0.11 and see if the issue is solved.

Unfortunately without access to your platform and software, and without a repeatable testcase, I can't debug this any further.
[28 Mar 2014 10:22] Alexander Soklakov
I close this report as "Can't repeat" because here is no feedback for a long time and codebase is too old. Please, feel free to reopen it if the problem still exists in current driver.