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

Java Client library does not support useServerPrepStmts

    XMLWordPrintable

Details

    • Epic
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 1.1.0, 1.2.0
    • 1.3.0
    • Other
    • None
    • Use server prepareStatement
    • Sprint connector/j 1.3.0

    Description

      To enable prepared statements on the server side, MySQL Connector/J provides useServerPrepStmts parameter.
      It doesn't work for MariaDB client. If there is a way to get prepared statements work through MariaDB client, I haven't yet found it.

      The provided test case checks the global value of Prepared_stmt_count status variable, then attempts to prepare a statement on a connection with useServerPrepStmts, then checks the variable value again.

      Output with MariaDB client library 1.1.0:

      Prepared_stmt_count before prepare: 0
      Prepared_stmt_count after prepare: 0

      With MySQL Connector/J 5.1.23:

      Prepared_stmt_count before prepare: 0
      Prepared_stmt_count after prepare: 1

      Test case:

      import java.sql.DriverManager;
      import java.sql.ResultSet;
      import java.sql.Statement;
      import java.sql.PreparedStatement;
       
       
      public class BugPreparedStatement
      {
        public static void main (String argv[])  
        {
          try {
       
            Statement status = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","").createStatement();
       
            ResultSet rs = status.executeQuery("show global status like 'Prepared_stmt_count'");
            if (rs.first()) {
              System.out.println("Prepared_stmt_count before prepare: " + rs.getInt(2));  
            }
       
            PreparedStatement pst = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?useServerPrepStmts=true","root","").prepareStatement("select 1");
       
            rs = status.executeQuery("show global status like 'Prepared_stmt_count'");
            if (rs.first()) {
              System.out.println("Prepared_stmt_count after prepare: " + rs.getInt(2));  
            }
          }
          catch (Exception e)
          {
            System.out.println("Exception: " + e + "\n");
            e.printStackTrace();
          }
        } 
      }
       

      Attachments

        Issue Links

          Activity

            People

              diego dupin Diego Dupin
              elenst Elena Stepanova
              Votes:
              1 Vote for this issue
              Watchers:
              11 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.