[CONJ-244] NPE in AbstractQueryProtocol with no parameters caused by some prepared statements Created: 2016-01-12 Updated: 2016-02-24 Resolved: 2016-02-24 |
|
| Status: | Closed |
| Project: | MariaDB Connector/J |
| Component/s: | Other |
| Affects Version/s: | 1.3.3, 1.3.4, 1.3.5 |
| Fix Version/s: | 1.3.6 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Matthew Jones | Assignee: | Diego Dupin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
Our system is getting this NPE when starting up against a MySQL (5.6.23) database. I'm not seeing this against a MariaDB server. From what I can see in MariaDbServerPreparedStatement, if parameterCount is 0 it doesn't set parameterHolder to any value. It passes it along to executeInternal where it does a lookup against it and gets the NPE. This error did not happen on 1.2.2 (I don't believe 1.2.3 either) but I'm seeing it on 1.3.3 but might have been introduced earlier. Caused by: java.lang.NullPointerException |
| Comments |
| Comment by Diego Dupin [ 2016-01-12 ] | ||||||||
|
Hi Matthews and thanks to report this. This is a strange error, because after reading code to identify the problem, the only way that can cause this issue, is that when preparing query, server send back that there is no parameter. The thing is now to discover what kind of query can cause this. If you have any information about that, that would be great ! | ||||||||
| Comment by Matthew Jones [ 2016-01-12 ] | ||||||||
|
From what I can see, it looks like our application is failing when running through this schema creation. It's possible this code (most of it from 2005) isn't ideal, but it has run fine with every MySQL JDBC driver (and older MariaDB JDBC). It's just nice to be able to package this driver with the software because the license is better and it works nice. If it runs it on a regular statement/execute it looks to work fine, but not if it's a prepared statement. I'll attach a super simple test project that replicates this failure. (Edited on 2016-02-24 to provide correct statement that was run) CREATE TABLE CONTENT_COLLECTION CREATE UNIQUE INDEX CONTENT_COLLECTION_INDEX ON CONTENT_COLLECTION CREATE INDEX CONTENT_IN_COLLECTION_INDEX ON CONTENT_COLLECTION INSERT INTO CONTENT_COLLECTION VALUES ('/','', | ||||||||
| Comment by Matthew Jones [ 2016-01-12 ] | ||||||||
|
Attached All this is is a modified ScriptRunner that uses prepared statements. All you should have to do is create an empty database, modify the connection into in MariaTest.java (or leave it localhost/mariatest/mariatest) and run this. java -cp "mariadb-java-client-1.3.3.jar:." MariaTest I possibly could change our application code from prepareStatement to createStatement and it works but it works with both with other JDBC drivers and doesn't seem like it should matter and that would be a huge change. Thanks! | ||||||||
| Comment by Matthew Jones [ 2016-01-25 ] | ||||||||
|
Have you had any chance to look at this. I've confirmed that it's not the MySQL version. I've tested it also with MariaDB with the same NPE in the driver. This is a problem with 1.3.3 and 1.3.4. The maria-db-client-1.2.3 works fine. mysql Ver 15.1 Distrib 10.0.22-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2 Even running this query test (in the ZIP) against a MariaDB causes an NPE. java.lang.RuntimeException: Error running script. Cause: java.lang.NullPointerException | ||||||||
| Comment by Diego Dupin [ 2016-02-24 ] | ||||||||
|
Hi, The version 1.3.6 has corrected this issue for https://mariadb.atlassian.net/browse/CONJ-257.
(LONGVARCHAR alias datatype doesn't exist in mariadb. see data types : https://mariadb.com/kb/en/mariadb/data-types/ you must use MEDIUMTEXT.) | ||||||||
| Comment by Matthew Jones [ 2016-02-24 ] | ||||||||
|
It looks like my comment was incorrect, It's not actually LONGVARCHAR it's LONGTEXT (it is that LVC in the HSQLDB scripts which are deprecated). It's correct in the sql in the zip file which I used for the test and I updated my comment. Not sure how that was incorrect I'll retest with 1.3.6 since it's super easy to verify one way or another. Thanks! | ||||||||
| Comment by Matthew Jones [ 2016-02-24 ] | ||||||||
|
In either case, I just tested and 1.3.6 fixes this problem as well, you can mark this as resolved in 1.3.6. Thanks for the fix and update! | ||||||||
| Comment by Diego Dupin [ 2016-02-24 ] | ||||||||
|
Ok, i close the issue so. |