Description:
I changed a little to the test case in testsuite.regression.BlobRegressionTest.testBug5490(). I use an arbitrary file instead of creat a temp binary file, then a MySQLSyntaxErrorException is throwed.
my test code fragment:
// int blobFileSize = 871;
File blobFile = new File("d:/MDITabsDemo.rar");//newTempBinaryFile("Bug5490", blobFileSize);
PreparedStatement pStmt = this.conn.prepareStatement(sql,
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
pStmt.setInt(1, 2);
FileInputStream fis = new FileInputStream(blobFile);
pStmt.setBinaryStream(2, fis, (int)blobFile.length());
pStmt.execute();
fis.close();
pStmt.close();
the exception stacktrace:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?J?\0¢??_EEoó°T§??-Y¢\"??.¥?aד<?ROaT\';÷è???eü?GíO?eeDP??U£?èqLXe÷f?í·4' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.Util.getInstance(Util.java:381)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1031)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3376)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3308)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1837)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1961)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2543)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1737)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:998)
at testsuite.regression.BlobRegressionTest.testBug5490(BlobRegressionTest.java:236)
How to repeat:
Just use an arbitrary file instead of creat a regular temp binary file in the test case.
btw, the characterset I used is gbk.
Suggested fix:
Maybe there are some mistakes in escaping data improperly