Bug #21207 Connector/J debug version; (3.1.12) crashes and (3.1.13) does not log
Submitted: 21 Jul 2006 8:35 Modified: 19 Sep 2006 1:48
Reporter: Roberto Agostino Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S5 (Performance)
Version:3.1.12 - 3.1.13 OS:Microsoft Windows (Windows XP)
Assigned to: CPU Architecture:Any

[21 Jul 2006 8:35] Roberto Agostino
Description:
When I debug my code I need to trace the connector/J 3.1.12: so I used the debug connector/J 3.1.12 version with DEBUG level in log4j.properties; when it arrives to a preparedStatement, it crashes (if I use a higher level, it does not crash).

I upgraded to 3.1.13 (DEBUG level) and I noted that it does not crash, but the log trace (DEBUG) is reduced. 

I would have the same verbose log of 3.1.12 version, but without crashes. 

Thanks.

How to repeat:
The code used:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Testing
 * 
 * Autore: Agostino
 * Data:  21-lug-2006
 * 
 */

/**
 * @author Agostino
 *
 */
public class testPreparedStmt {

	/*
	 * == DATABASE SECTION ==================================================== 
	 * 
	 	# MySQL-Front 3.2  (Build 13.39)
	 	# Host: 10.60.4.50    Database: sst_v3_0
	 	# ------------------------------------------------------
	 	# Server version 4.0.23-Max-log

	 	CREATE DATABASE `sst_v3_0`;

	 	USE `sst_v3_0`;

		#
		# Table structure for table t_applicazione
		#

		CREATE TABLE `t_applicazione` (
		  `chiave` varchar(80) NOT NULL default '',
		  `valore` varchar(250) default NULL,
		  `commento` varchar(255) default NULL,
		  PRIMARY KEY  (`chiave`)
		) TYPE=InnoDB COMMENT='Tabella dei parametri di applicazione (condivisi)';
		
	 * 
	 * == LIBRARY SECTION =====================================================
	 * 
	 *  mysql-connector-java-3.1.12-bin-g.jar  	debug versione for connector
	 *  src/lib/aspectjrt.jar									 	for debub version of connector											
	 * 
	 *  log4j-1.2.9.jar                         for the logger
	 * 
	 * == log4j.properties ====================================================
	 * 
	 log4j.rootLogger=DEBUG, stdout
	 
	 # Console output...
	 log4j.appender.stdout=org.apache.log4j.ConsoleAppender
	 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
	 log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%t] - %m%n	 
	 * 
	 */
	
	// access to db url and credentials
	static String jdbcURL = "jdbc:mysql://SST_DB/sst_v3_0";
	static String dbUserName = "sst_user";
	static String dbPassword = "sst_user";
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {

		try {
			//connessione al db
			Class.forName("org.gjt.mm.mysql.Driver");			
			Connection c = DriverManager.getConnection(jdbcURL, dbUserName, dbPassword); 
						
			// esecuzione della query
			PreparedStatement ps = c.prepareStatement("select * from t_applicazione");
			ResultSet rs = ps.executeQuery();

			while (rs.next() ) {
				String sCol1 = rs.getString(1);
				String sCol2 = rs.getString(2);
				
				System.out.println("> "+sCol1+":\t "+sCol2);
			}
			
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}		
	}

}
[21 Jul 2006 12:20] Roberto Agostino
The crash succeeds in the method asSql(boolean), because the parameters array is null (I used a preparedStatement without parameter) and the index is 1; when it arrives to array[1] --> Nullpointer.exception. When I have a higher debug level the asSql(boolean) method is not invoked.
[29 Aug 2006 19:00] Tonci Grgin
Roberto thanks for your problem report.

Looks like the bugfix we used doesn't work for the case of prepared statement with no parameters. Basically, we check if parameters are null which means statement is closed, and eligible for GC as far as the driver's concerned, but client my still have access to it.
I don't know what you mean by "log trace (DEBUG) is reduced." though.
We were unable to reproduce crash with 3.1.12 so I would have to ask you to provide full stack trace, and your log.
[30 Aug 2006 6:47] Roberto Agostino
Four log files of versions 3.1.12 and 3.1.13, in debug and error level log.

Attachment: logs.zip (application/x-zip-compressed, text), 15.08 KiB.

[30 Aug 2006 6:52] Roberto Agostino
I uploaded a zip archive with four log files. There are the 2 files for version 3.1.12 (free crash the error level and debug level with crash), and the other 2 for version 3.1.13, both without crashes, although the log seems the same.
[30 Aug 2006 18:10] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/11096