Bug #8142 Update via callableStatement crash mySQL server
Submitted: 26 Jan 2005 12:27 Modified: 18 Jun 2006 20:50
Reporter: Sergi Vergés Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.0.2-alpha-nt OS:Windows (Windows)
Assigned to: CPU Architecture:Any

[26 Jan 2005 12:27] Sergi Vergés
Description:
When I execute a piece of java code in a jsp like the following, the server crashes. I'm using mysql-connector-java-3.1.6 and 5.0.2-alpha-nt versions.

if (cstmt!=null) cstmt.close(); 
cstmt = ( CallableStatement )conn.prepareCall(
   "{ call st_proc_name(?, ?, ?, ?, ?) }" );
   
cstmt.setString( 1, "1");
cstmt.setString( 2, "24-01-2005");
cstmt.setString( 3, "300");
cstmt.setString( 4, "500");
cstmt.setString( 5, "hola");

cstmt.execute();
conn.commit();

if (cstmt!=null) cstmt.close(); 
cstmt = ( CallableStatement )conn.prepareCall(
   "{ call st_proc_name(?, ?, ?, ?, ?) }" );

cstmt.setString( 1, "1");
cstmt.setString( 2, "24-01-2005");
cstmt.setString( 3, "500");
cstmt.setString( 4, "600");
cstmt.setString( 5, "bye");

cstmt.execute();
conn.commit();

How to repeat:
Create a table:
CREATE TABLE TABLE_NAME
  (
  TABLE_NAME_ID INTEGER  AUTO_INCREMENT NOT NULL PRIMARY   KEY,
  DATA DATE NOT NULL,
  A INTEGER,
  B INTEGER,
 );

CHANGE DELIMITER TO //

Create a stored procedure:
  CREATE PROCEDURE st_proc_name(IN p_id CHAR(10),
				  IN p_data CHAR(10),
				  IN p_a CHAR(10),
				  IN p_b CHAR(10))
BEGIN
  UPDATE table_name
  SET a=p_a,
      b=p_b
  WHERE TABLE_NAME_ID= p_Id
    AND DATA = STR_TO_DATE(p_data,'%d-%m-%Y');
END				  
//

create a jsp that executes the piece of code given.

when running the jsp you receives the error:
com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: 

** BEGIN NESTED EXCEPTION ** 

java.net.SocketException
MESSAGE: Connection reset

STACKTRACE:

java.net.SocketException: Connection reset
	at java.net.SocketInputStream.read(SocketInputStream.java:168)
	at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:75)
	at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:94)
	at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:122)
	at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1842)
	at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2292)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2788)
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1534)
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1625)
	at com.mysql.jdbc.Connection.execSQL(Connection.java:2297)
	at com.mysql.jdbc.Connection.execSQL(Connection.java:2226)
	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1812)
	at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1448)
	at com.mysql.jdbc.CallableStatement.execute(CallableStatement.java:730)
	at _produccio._produccio__action_2e_jsp._jspService(_produccio__action_2e_jsp.java:428)
	at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
	at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:365)
	at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:519)
	at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:423)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
	at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:771)
	at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:298)
	at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:829)
	at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
	at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
	at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:291)
	at java.lang.Thread.run(Thread.java:534)

** END NESTED EXCEPTION **

	at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2504)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2788)
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1534)
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1625)
	at com.mysql.jdbc.Connection.execSQL(Connection.java:2297)
	at com.mysql.jdbc.Connection.execSQL(Connection.java:2226)
	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1812)
	at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1448)
	at com.mysql.jdbc.CallableStatement.execute(CallableStatement.java:730)
	at _produccio._produccio__action_2e_jsp._jspService(_produccio__action_2e_jsp.java:428)
	at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
	at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:365)
	at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:519)
	at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:423)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
	at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:771)
	at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:298)
	at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:829)
	at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
	at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
	at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:291)
	at java.lang.Thread.run(Thread.java:534)
[27 Jan 2005 6:23] Aleksey Kishkin
some notes:

- stored procedure you wrote has 4 arguments. You call it with 5 args;
- CHANGE DELIMITER TO // leads to error, I tested with DELIMITER //
- CREATE TABLE TABLE_NAME ( ........ B INTEGER, ) leads to error. I removed wrong "," for testing.

Ok. it works without crash on linux, and I am going to try it on windows.
[7 Feb 2005 12:56] Aleksey Kishkin
tested on winxp also. 

I am attaching a test case.
[7 Feb 2005 12:57] Aleksey Kishkin
test case

Attachment: bug8142.java (application/octet-stream, text), 1.48 KiB.

[16 Feb 2005 12:15] niranjan railkar
same problem i am with mysql 5.0.2-alpha-nt on windows OS
any solution to this
[24 Feb 2005 14:51] Mark Matthews
Dupe of http://bugs.mysql.com/bug.php?id=8754

Connector/J uses the various 'SHOW' commands related to stored procedures to retrieve metadata it needs to execute the statement. These commands crash 5.0.2 on windows.
[24 Feb 2005 15:22] Mark Matthews
Appears to be a new and different server issue. This is the SQL that the driver generates (gathered by adding 'profileSQL=true' to the URL).

When I run this script on windows, MySQL-5.0.2 dies with a 'pure virtual function call' error:

DROP TABLE IF EXISTS TABLE_NAME;
CREATE TABLE IF NOT EXISTS TABLE_NAME(TABLE_NAME_ID INTEGER  AUTO_INCREMENT NOT
NULL PRIMARY   KEY,DATA DATE NOT NULL,A INTEGER,B INTEGER);
DROP PROCEDURE IF EXISTS st_proc_name;
DELIMITER |;
CREATE PROCEDURE st_proc_name(IN p_id CHAR(10),IN p_data CHAR(10),
IN p_a CHAR(10),
IN p_b CHAR(10))
BEGIN
UPDATE TABLE_NAME
SET a=p_a,
b=p_b
WHERE TABLE_NAME_ID= p_Id
AND DATA = STR_TO_DATE(p_data,'%d-%m-%Y');
END|
DELIMITER ;|
CALL st_proc_name('1', '24-01-2005', '300', '500');
SHOW CREATE PROCEDURE st_proc_name;
CALL st_proc_name('1', '24-01-2005', '500', '600');
DROP PROCEDURE IF EXISTS st_proc_name; DROP TABLE IF EXISTS TABLE_NAME;
[10 Mar 2005 13:05] Bas Wijngaard
I don't really know if it is the same problem. 

On my devlopmachine (Windows XP SP2 Pro NL) i use IIS for webserver, with php installed. I just installed MySQL 5.0.2 because i wanted to use triggers for a school project. 

For managing the database i use PhpMyAdmin. But when a logon to my database with it, and click on one of the tables shown at the left, the mysql server crashes. Windows tells me that there was an error in mysqld-nt.exe and that it must be shut down.
[5 Apr 2005 3:13] MySQL Verification Team
Could you please test this issue with the latest release 5.0.3 ?

Thanks in advance.
[5 May 2005 23: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".
[18 May 2006 20:50] Valeriy Kravchuk
Can you repeat the same crash with newer version of MySQL server, 5.0.21?
[18 Jun 2006 23: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".