Odd UUID to BOOLEAN conversion error

32 views
Skip to first unread message

Caltinor

unread,
Jan 21, 2021, 2:51:27 AM1/21/21
to H2 Database
Hello Everyone,

I am having a rather strange issue with an update statement.  I am using a preparedstatement to execute and update statement and passing 3 parameters (UUID, String, int).  when I execute the update i get this error

"org.h2.jdbc.JdbcSQLDataException: Data conversion error converting "UUID to BOOLEAN"; SQL statement:
UPDATE MARKET_GLOBAL SET BUYER =? AND BUYER_NAME =? WHERE ID =? [22018-200]"

I have confirmed the variable being passed into the UUID is not null, and that the field type is declared as UUID.

To make things more interesting, i created a new method ("test()") and replicated the code, then passed the same variables via this method and it worked.  i then called the failing method within the same run instance and it failed.

Here is my github with the class in reference: https://github.com/Caltinor/GnCLib/blob/main/src/dicemc/gnclib/trade/dbref/H2Impl.java I am calling executeTransaction which is failing on the first if (it works fine if the count does not equal the entry stock).  another thing worth noting is i am calling getMarketList(...) before i call executeTransaction(...).

Any help is greatly appreciated.

-Caltinor

Noel Grandin

unread,
Jan 21, 2021, 5:02:46 AM1/21/21
to H2 Database
That smells like the kind of bug that H2 sometimes has with determining the type of a parameter in a PreparedStatement.

Normally it can be worked around by using CAST around the ? so that H2 knows exactly what type to use there.

Possibly we could track down the bug if you can provide a standalone test-case.

Caltinor

unread,
Jan 21, 2021, 5:32:49 AM1/21/21
to H2 Database
I am happy to try to create a standalone test case, however that might be easier said than done.  

As I pointed out, I replicated the code in another method, used the same input variables, and the update statement worked.  I do have another update statement that assigns a UUID that I suspect might have the same issue.  If i can find a commonality between them that would give me enough to work with for a test case i will certainly build that and provide it here.

Until then, I will use CAST for this case.  Thank you for your help.

Caltinor

unread,
Jan 21, 2021, 11:08:22 AM1/21/21
to H2 Database
I wanted to follow up on this.  I did resolve the issue though the problem was entirely caused by a novice mistake on my part.  I used "AND" in the SET portion of the update statement instead of ", ".  so the assignments were being treated like expressions and confusing the database.  original statement for reference to my error.

UPDATE MARKET_GLOBAL SET BUYER =? AND BUYER_NAME =? WHERE ID =? 

Correct

UPDATE MARKET_GLOBAL SET BUYER =?, BUYER_NAME =? WHERE ID =? 

Reply all
Reply to author
Forward
0 new messages