Description:
I use the mysql database server version 5.0.18 shiped by OpenSuSE 10.1. If i execute a prepared statement with the Connector/J 3.1.13 everything works fine. But i get an exception on using exactly same with Connector/J 3.1.14.
Caused by: java.sql.SQLException: Incorrect arguments to mysql_stmt_execute
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2975)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1600)
at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1129)
at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:681)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1368)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1283)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1268)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:251)
at my.DAO.insertVersion(DAO.java:310)
How to repeat:
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import junit.framework.TestCase;
/**
* DB Table created by following statement
*
* use mydb;
*
* ##
* ## Table structure for table `theTable`
* ##
* DROP TABLE IF EXISTS `theTable`;
* CREATE TABLE `theTable` (
* `businessId` int(11) default NULL,
* `fromDate` date NOT NULL default '0000-01-01',
* `name` varchar(100) default NULL,
* `rate` decimal(5,2) NOT NULL,
* `toDate` date NOT NULL default '9999-12-31',
* `userId` varchar(100) default NULL,
* `changeDate` bigint(20) NOT NULL,
* PRIMARY KEY (`fromDate`, `businessId`)
* ) TYPE=InnoDB;
*
* @author per.n
*
* $RCSfile: DBTest.java,v $
* $Author: per.n $
* $Date: 21.11.2006 $
* $Revision: 1.0 $
*/
public class DBTest extends TestCase {
private Connection connection = null;
/**
* @see TestCase#setUp()
*/
protected void setUp() throws Exception {
super.setUp();
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection("jdbc:mysql://localhost/mydb",
"mydbuser", null);
}
/**
* @see TestCase#tearDown()
*/
protected void tearDown() throws Exception {
super.tearDown();
connection.close();
}
/**
* Test a prepared statement.
*/
public void testStatement() {
try {
PreparedStatement p = connection.prepareStatement("insert into theTable (businessId, fromDate, name, rate, toDate, userId, changeDate) values (?, ?, ?, ?, ?, ?, ?)");
p.setInt(1, 1);
p.setDate(2, new Date(1142246561452L));
p.setString(3, "keine Steuern");
p.setBigDecimal(4, new BigDecimal(0.00d));
p.setDate(5, new Date(1142246561452L));
p.setString(6, "admin");
p.setLong(7, 1142246561452L);
p.executeUpdate();
} catch (SQLException e) {
fail(e.getMessage());
}
}
}
Description: I use the mysql database server version 5.0.18 shiped by OpenSuSE 10.1. If i execute a prepared statement with the Connector/J 3.1.13 everything works fine. But i get an exception on using exactly same with Connector/J 3.1.14. Caused by: java.sql.SQLException: Incorrect arguments to mysql_stmt_execute at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2975) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1600) at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1129) at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:681) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1368) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1283) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1268) at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:251) at my.DAO.insertVersion(DAO.java:310) How to repeat: import java.math.BigDecimal; import java.sql.Connection; import java.sql.Date; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; import junit.framework.TestCase; /** * DB Table created by following statement * * use mydb; * * ## * ## Table structure for table `theTable` * ## * DROP TABLE IF EXISTS `theTable`; * CREATE TABLE `theTable` ( * `businessId` int(11) default NULL, * `fromDate` date NOT NULL default '0000-01-01', * `name` varchar(100) default NULL, * `rate` decimal(5,2) NOT NULL, * `toDate` date NOT NULL default '9999-12-31', * `userId` varchar(100) default NULL, * `changeDate` bigint(20) NOT NULL, * PRIMARY KEY (`fromDate`, `businessId`) * ) TYPE=InnoDB; * * @author per.n * * $RCSfile: DBTest.java,v $ * $Author: per.n $ * $Date: 21.11.2006 $ * $Revision: 1.0 $ */ public class DBTest extends TestCase { private Connection connection = null; /** * @see TestCase#setUp() */ protected void setUp() throws Exception { super.setUp(); Class.forName("com.mysql.jdbc.Driver").newInstance(); connection = DriverManager.getConnection("jdbc:mysql://localhost/mydb", "mydbuser", null); } /** * @see TestCase#tearDown() */ protected void tearDown() throws Exception { super.tearDown(); connection.close(); } /** * Test a prepared statement. */ public void testStatement() { try { PreparedStatement p = connection.prepareStatement("insert into theTable (businessId, fromDate, name, rate, toDate, userId, changeDate) values (?, ?, ?, ?, ?, ?, ?)"); p.setInt(1, 1); p.setDate(2, new Date(1142246561452L)); p.setString(3, "keine Steuern"); p.setBigDecimal(4, new BigDecimal(0.00d)); p.setDate(5, new Date(1142246561452L)); p.setString(6, "admin"); p.setLong(7, 1142246561452L); p.executeUpdate(); } catch (SQLException e) { fail(e.getMessage()); } } }