Bug #28689 Parameters of stored procedures are not recognized using executeBatch
Submitted: 25 May 2007 19:31 Modified: 11 Sep 2007 16:40
Reporter: William Chiquito Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S1 (Critical)
Version:5.0.3, 5.0.7 OS:Windows (XP SP2)
Assigned to: CPU Architecture:Any

[25 May 2007 19:31] William Chiquito
Description:
When I place the parameter noAccessToProcedureBodies=true in the connection string the parameters of stored procedures are not recognized using executeBatch().

How to repeat:
Craate table:

CREATE TABLE `t1` (
  `id` int(11) NOT NULL auto_increment,
  `usuario` varchar(255) collate latin1_spanish_ci default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_spanish_ci;

INSERT INTO t1 (usuario) VALUES ('AAAAAA');

Create stored procedure:

DELIMITER $$

DROP PROCEDURE IF EXISTS `mysp`$$

CREATE PROCEDURE `mysp`(tid INT)
BEGIN
	UPDATE t1 SET usuario = 'BBBBBB' WHERE id = tid;
END$$

DELIMITER ;

SHOW GRANTS FOR 'myuser';

Grants for myuser@%                                                                                  
--------------------------------------------------------------------------------------------------------
GRANT USAGE ON *.* TO 'myuser'@'%' IDENTIFIED BY PASSWORD '*312BD110EBF610B19DD0119CF075E0C6532BA38D'
GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE ON `mydatabese`.* TO 'myuser'@'%'                  

-- NO GRANT SELECT mysql.proc

Page:

<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>

<%

String connectionURL = "jdbc:mysql://localhost:3306/mydatabese?user=myuser&password=mypassword&noAccessToProcedureBodies=true";

Connection connection = null;
CallableStatement stmt = null;

%>

<%@page contentType="text/html"%>
<%@page pageEncoding="ISO-8859-1"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>MySQL BUG</title>
</head>
<body>

<%
Class.forName("com.mysql.jdbc.Driver").newInstance();

connection = DriverManager.getConnection(connectionURL);

stmt = connection.prepareCall("{ call mysp(?) }");

stmt.setInt(1, 1);

stmt.addBatch();
int[] updateCounts = stmt.executeBatch();

out.print("UPDATE: " + updateCounts[0]);

stmt.close();

connection.close();
connection = null;

%>

</body>
</html>

Result:

SELECT * FROM t1;

    id  usuario
------  -------
     1  AAAAAA
[26 Jun 2007 7:27] Sveta Smirnova
test case

Attachment: bug28689.java (text/plain), 1.26 KiB.

[26 Jun 2007 7:29] Sveta Smirnova
Thank you for the report.

Verified as described.
[4 Sep 2007 16:55] 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/33652
[4 Sep 2007 17:31] 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/33653
[4 Sep 2007 17:34] 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/33654
[4 Sep 2007 18:45] Mark Matthews
Will be in 5.0.8/5.1.3.
[6 Sep 2007 15:14] 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/33832
[7 Sep 2007 14:04] 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/33909
[11 Sep 2007 16:40] MC Brown
A note has been added to the 5.0.8 and 5.1.3 changelogs: 

CallableStatement.executeBatch() doesn't work when connection property noAccessToProcedureBodies has been set to true.

The fix involves changing the behavior of noAccessToProcedureBodies,in that the driver will now report all paramters as "IN" paramters but allow callers to call registerOutParameter() on them without throwing an exception.
[3 Oct 2007 16:42] 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/34839
[3 Oct 2007 16:46] 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/34840
[3 Oct 2007 18:59] 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/34855
[5 Oct 2007 18:53] 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/35011
[11 Oct 2007 20:11] 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/35407
[11 Oct 2007 20:24] 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/35410
[11 Oct 2007 20:52] 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/35414
[19 Nov 2007 0:57] 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/38019
[19 Nov 2007 2:51] 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/38024