Bug #5375 | Put Some Big File to BLOB is error | ||
---|---|---|---|
Submitted: | 2 Sep 2004 18:56 | Modified: | 7 Sep 2004 22:11 |
Reporter: | Liu Naijia | Email Updates: | |
Status: | Can't repeat | Impact on me: | |
Category: | Connector / J | Severity: | S1 (Critical) |
Version: | 3.1.3-beta | OS: | Any (Any) |
Assigned to: | CPU Architecture: | Any |
[2 Sep 2004 18:56]
Liu Naijia
[7 Sep 2004 22:09]
Eric Herman
I couldn't repeat this error with Connector/J 3.1.4 newConn = DriverManager.getConnection(url, "root", ""); stmt0 = newConn.createStatement(); stmt0.executeUpdate("DROP TABLE IF EXISTS testBug5375"); stmt0.executeUpdate("CREATE TABLE testBug5375" + "(pk INT NOT NULL PRIMARY KEY, blobField BLOB)"); String sql = "insert into testBug5375 values(?,?)"; int blobFileSize = (int) (1.5 * 1024 * 1024); // 1.5MB File blobFile = newTempBinaryFile("Bug5375", blobFileSize); PreparedStatement stmt1 = newConn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); stmt1.setInt(1, 2); FileInputStream str = new FileInputStream(blobFile); stmt1.setBinaryStream(2, str, -1); stmt1.execute(); str.close(); stmt1.close(); ----------------------------------- private File newTempBinaryFile(String name, int size) throws IOException { File tempFile = File.createTempFile(name, "tmp"); tempFile.deleteOnExit(); FileOutputStream fos = new FileOutputStream(tempFile); BufferedOutputStream bos = new BufferedOutputStream(fos); for (int i = 0; i < size; i++) { bos.write((byte) i); } bos.close(); assertTrue(tempFile.exists()); assertEquals(size, tempFile.length()); return tempFile; }
[8 Sep 2004 0:32]
Liu Naijia
Olny some files are not put into BLOB fileds.Please test file "mysql-connector-java-3.1.3-beta.zip"
[8 Sep 2004 0:40]
Liu Naijia
I find you must use "useUnicode=true&characterEncoding=GBK" in url then you can find the error.
[8 Sep 2004 1:35]
Eric Herman
The url I use is: String url = "jdbc:mysql:///test" + "?useUnicode=true&characterEncoding=GBK"; I would like to know if you see the problem if you adapt the test case I provided.
[8 Sep 2004 1:55]
Liu Naijia
the test case which used "useUnicode=true&characterEncoding=GBK" is good. but some files such as mysql-connector-java-3.1.3-beta.zip can't work
[8 Sep 2004 16:58]
Eric Herman
I don't happen to have a copy of the 3.1.3-beta.zip handy. However, the following change made no difference: --------------- //File blobFile = newTempBinaryFile("Bug5375", blobFileSize); File blobFile = new File("/home/eric/dload/zip/mysql-connector-java-3.1.4-beta.zip"); --------------- Liu, does a test case using the "newTempBinaryFile" fail for you?
[9 Sep 2004 1:01]
Liu Naijia
Your url is "useUnicode=true&characterEncoding=GBK" and your database character is gbk? I test your application. It can run.I change url to "jdbc:mysql:///test",It can run.But I must use characterEncoding=GBK,it can not run.I'm puzzled.
[9 Sep 2004 1:05]
Liu Naijia
I'm sorry. I didn't say clearly. Your program which is used tempfile can run at all time. My Program which is used 'mysql-connector-java-3.1.3-beta.zip' can not run when url is 'jdbc:mysql:///test/useUnicode=true&characterEncoding=GBK'