[CONJ-104] Malformed communication exception if getMetaData before executeQuery Created: 2014-08-06 Updated: 2014-10-13 Resolved: 2014-10-10 |
|
| Status: | Closed |
| Project: | MariaDB Connector/J |
| Component/s: | None |
| Affects Version/s: | 1.1.7 |
| Fix Version/s: | 1.1.8 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Fabien Morand | Assignee: | Massimo Siani (Inactive) |
| Resolution: | Not a Bug | Votes: | 1 |
| Labels: | None | ||
| Environment: |
Windows XP, MySQL, Java application, BIRT (report) |
||
| Attachments: |
|
| Description |
|
Problem was discovered while using BIRT, and can be reproduced with a simple java class. If you create a PreparedStatement, and call getMetaData() method before executeQuery(), then you will get an error when executeQuery() is called. Error is: Quick fix: However this fix is probably not the best solution. If executeQuery() has not been called, then a new PreparedStatement has to be created in order to gather the metadata. This seems to be done by MySQLServerSidePreparedStatement, however something seems to go wrong when closed() is called. Simple code to reproduce the problem: import java.sql.Connection; public class TestClass { public static void main(String[] args) { catch(Exception e) { e.printStackTrace(); } } |
| Comments |
| Comment by Fabien Morand [ 2014-08-08 ] |
|
Here is a better fix proposal: public ResultSetMetaData getMetaData() throws SQLException { try { for (int i = 1; i <= paramCount; i++) { ssps.setString(i, ""); }boolean hasResults = ssps.execute(); if(hasResults) { rs = ssps.getResultSet(); rsmd = rs.getMetaData(); }else { rsmd = new MySQLResultSetMetaData(new MySQLColumnInformation[0], 0); } } finally { if(rs != null) { rs.close(); }} return rsmd; |
| Comment by Massimo Siani (Inactive) [ 2014-09-29 ] |
|
Could you please check out https://code.launchpad.net/~massimo-siani/mariadb-java-client/CONJ-104 and tell why I don't get the same issue? |
| Comment by Fabien Morand [ 2014-10-08 ] |
|
Can you provide an archive with the classes ? Bazaar is annoying me with certificate issue, and I don't have time to spend making it work. Thank you. |
| Comment by Massimo Siani (Inactive) [ 2014-10-08 ] |
|
Attached. |
| Comment by Fabien Morand [ 2014-10-09 ] |
|
Here is the jar that I use. I do have the problem, even with a very simple query. I will now try with your linked 1.1.8 jar. java.sql.SQLException: Malformed communication packet. |
| Comment by Fabien Morand [ 2014-10-09 ] |
|
I tried with the 1.1.8 preview jar and I still get the same error. If getMetadata is called before executeQuery, then I get the error. |
| Comment by Massimo Siani (Inactive) [ 2014-10-10 ] |
|
I have been able to reproduce this bug with MySQL server only, not with MariaDB. MySQL is known to behave this way (not sure if http://bugs.mysql.com/bug.php?id=70664 is related in any way). MariaDB server (5.5.40 and 10.0.14) does not suffer from the same bug. Do you have any chance to test it? I tested with MySQL 5.6.21 on CentOS, the OS should be irrelevant. Your workaround can work, but this is not a driver bug. |
| Comment by Fabien Morand [ 2014-10-13 ] |
|
Thank you for your time, our target is MySQL so we will keep it this way. |