[CONJ-9] Valid SQL query throws an SQLSyntaxException Created: 2013-01-09 Updated: 2014-06-20 Resolved: 2013-01-15 |
|
| Status: | Closed |
| Project: | MariaDB Connector/J |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 1.1.0 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Heiko Tropartz (Inactive) | Assignee: | Vladislav Vaintroub |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Ubuntu 12.04 |
||
| Description |
|
We switched from MySQL JDBC driver to the SkySQL JDBC driver. <code>SELECT `call`.`call_id` FROM `statistic`.`call` `call`</code> It seems the problem occurs because the table alias equals the table name. If we change it to (i.e. "e") then it works. The SQL queries are generated by Crystal Report at run-time so we have no impact. And with the MySQL/Solid/Postgres JDBC driver it works. I also created a discussion in support forum: There you will also find a short stack-trace. |
| Comments |
| Comment by Vladislav Vaintroub [ 2013-01-09 ] |
|
Are you sure did not mix anything there? The stacktrace you refer to, is from earlier unreleased version of the driver, as indicated by presence of "org.skysql" packages. the MariaDB-JDBC has "org.mariadb" packages I'm not able to reproduce with the below test, using the 1.0.0 MariaDB-JDBC driver? I created database statistic and table call with int call_id in it prior to the test. Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root",""); |
| Comment by Vladislav Vaintroub [ 2013-01-09 ] |
|
The 1.0.0 version of MariaDB JDBC can be downloaded from https://downloads.mariadb.org/client-java/1.0.0/ |
| Comment by Heiko Tropartz (Inactive) [ 2013-01-09 ] |
|
I'm sorry - cut, copy, paste problem. Here is a brand new stack-trace: Caused by: java.sql.SQLSyntaxErrorException: 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 '.`call` `call`' at line 1 |
| Comment by Vladislav Vaintroub [ 2013-01-09 ] |
|
Thanks Heiko. However I still have difficulty reproducing the problem - c.createStatement().executeQuery("SELECT `call`.`call_id` FROM `statistic`.`call` `call`") Can you create a similarly small example to illustrate the problem? |
| Comment by Heiko Tropartz (Inactive) [ 2013-01-10 ] |
|
Hello, I made a lot of test and you are right. With a simple test application it works. But the same SQL string generated by Crystal Report or injected during runtime did not work. We are using log4j, is it possible to enable more detailed logging from MariaDB client library? Thanks and best regards, |
| Comment by Vladislav Vaintroub [ 2013-01-10 ] |
|
More detailed logging is not possible at the moment in the 1.0.0 I would be very helpful to enable general log (SET GLOBAL general_log = 'ON' , with powerful user account, and switching it OFF after the end of the experiment) to see the queries as they come on the server side. While this still might be insufficient to analyze the error (e.g with prepared statements, or query could have changed after normalization with nativeSQL), but it might give some clue. It is probably worth checking if CrystalReports has itself any kind of JDBC tracing If none of the above is not possible on some reason, just tell, and I'll build a custom jar that dumps more info on syntax exceptions. |
| Comment by Heiko Tropartz (Inactive) [ 2013-01-11 ] |
|
Hello, after analyzing a huge amount of logs, I found 2 differences between the MySQL J/Connector and the MariaDB client library. 1. When the Crystal Report engine tries to access the database via the MariaDB library, I found the following log message several times: org.mariadb.jdbc.CommonDatabaseMetaData getUDTs 2. The Crystal Report engine creates different SQL queries. MariaDB: SELECT `new_table`.`test` FROM `def`.`test`.`new_table` `new_table` I don't know if the 'def' in front of 'test'.'new_table' has something to do with the empty ResultSet of getUTDs, but these are the only differences I found. I think the 'def' string is wrong and that is the reason for the SQLSyntaxException from the MariaDB client library. |
| Comment by Vladislav Vaintroub [ 2013-01-14 ] |
|
Good, you second hint seems correct . The query indeed throws syntax error. However I would certainly appreciate if you can test the JDBC dirver before the release. For your convenience, I built the from the latest source, and uploaded to my skydrive : https://skydrive.live.com/#cid=FF0C950417B4F8A4&id=FF0C950417B4F8A4%21110 |
| Comment by Heiko Tropartz (Inactive) [ 2013-01-14 ] |
|
Very good, the version from your skydrive works. Thank you very much for your help. |