Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-104

Malformed communication exception if getMetaData before executeQuery

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Not a Bug
    • 1.1.7
    • 1.1.8
    • None
    • None
    • Windows XP, MySQL, Java application, BIRT (report)

    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:
      SQL error #1:Malformed communication packet.
      (full log in file)

      Quick fix:
      In order to advance in our work, we have found a quick fix. We have commented the following instruction in MySQLPreparedStatement.getMetaData() method:
      //ssps.close();

      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;
      import java.sql.DriverManager;
      import java.sql.PreparedStatement;
      import java.sql.ResultSet;

      public class TestClass {

      public static void main(String[] args) {
      try

      { Connection connection = DriverManager.getConnection("jdbc:mysql://127.0.0.1:..."); PreparedStatement ps = connection.prepareStatement("select ..."); ps.getMetaData(); ResultSet rs = ps.executeQuery(); ps.close(); connection.close(); }

      catch(Exception e)

      { e.printStackTrace(); }

      }
      }

      Attachments

        Activity

          People

            massimo.siani Massimo Siani (Inactive)
            fabien.morand Fabien Morand
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.