-
Notifications
You must be signed in to change notification settings - Fork 627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PreparedStatement setBytes() #78
Comments
Thanks for reporting. This sounds serious. Could you give me a sample query (and code) to reproduce this issue? Thanks. |
Hello, The test case code I have created to provide is not duplicating the behavior like the application Without changing anything other then the build jars, 3.8.10.1 to the current exempts the I would not classify this as a BUG at this time without further work on my end. danap. |
Hello, After further analysis, I have determined this is not related to the I have created a test case that demonstrates the issue. I do not The application uses what has been a general safe getString() to I have ran into a similar issue with Oracle, HyperSQL, and MSAccess. The application has been updated to insure this is no longer an Test Case: http://dandymadeproductions.com/temp/ Thank you for your work with the sqlite-jdbc driver. By the way the danap. |
I agree that this is a change in behavior of sqlite-jdbc. Sorry about that. But keep in mind that JDBC drivers don't need to support getBytes() for strings at all. Look at the table B-6 in the JDBC 4.1 specification ("Use of ResultSet getter Methods to Retrieve JDBC Data Types") Behavior when reading a string before commit a4cf82d:
Behavior when reading a string after commit a4cf82d:
Maybe it would make sense to always return UTF-8 when getBytes() is called on a string?
I have created a pull request for this. |
Hello Michael, The test case was only using strings to simplify the code to demonstrate the The issue I think is the ResultSet read, first with getString() then getBytes() In each of the databases my application supports, other then the ones mentioned, I would not recommend the new pull request => getString(); getBytes(); => UTF-8 danap. |
In my proposed pull request, the conversion to UTF-8 is done only for TEXT. Binary data (BLOB) is never modified. SQLite does not perform any conversions that would produce malformed data. See https://sqlite.org/c3ref/column_blob.html The question is: What character encoding shall getBytes() use for TEXT? I propose to always use UTF-8, because that's what your original code expected. It's also the native format for databases created by sqlite-jdbc. |
Hello Michael,
I'm sure it does not since I have already demonstrated with the test case that the In the test case I provided there is a method testBlobs() with a commented call As far as BLOB fields I have no idea what a user may wish to place in them As indicated, somewhere after sqlite-jdbc 3.8.10.1/2 this behavior turned up.
Then that is the answer to your question for a TEXT defined field. danap. |
Hi danap, thank you for the example program and the explanations. I have been able to reproduce the problem. "getString(); getBytes();" on a BLOB indeed changes the blob's data. I will try to create a bugfix. Regards, |
Hello Michael, I started thinking overnight about this issue. I did look at the sqlite-jdbc It appeared to me that the driver does a test on content by a typeof to I briefly looked to see if my application could try to do a typeof, but I really think the current code is acceptable, from my limited knowledge The only possible issue that I can point out is, after reviewing the Dana M. Proctor |
Hello,
Somewhere between Release 3.8.10.2 and current code the PreparedStatement setBytes()
has been changed that results in what appears to be twice the byte size being stored in the
database. I'm not sure if getBytes() is the issue. This results in corrupt BLOB type being
stored.
A cursory look appears it maybe around the changes in the Kaufmann, (character > U+FFFF)
commit with the JDBC3PreparedStatement. I suppose it might also have to do with the native
library. Currently I'm using the Linux/64bit one. I have not tested on Windows or 32 bit machines.
danap.
The text was updated successfully, but these errors were encountered: