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

prepareCall() for SELECT statement throws exception

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Not a Bug
    • 1.1.4
    • None
    • None
    • Ubuntu64 connecting to MariaDB 10.0.4 locally

    Description

      prepareCall() parses and returns a CallableStatement, a subclass of PreparedStatement in JDBC.

      In both the Oracle ojdbc6 (connecting to an Oracle DB) and MySQL/J Connector drivers, doing the following works fine (of course the Oracle query selected from different table/schema):

      scala> import com.mysql.jdbc.Driver
      import com.mysql.jdbc.Driver
       
      scala> import java.sql._
      import java.sql._
       
      scala> val conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql", "root", "***")
      conn: java.sql.Connection = com.mysql.jdbc.JDBC4Connection@59f66488
       
      scala> val stmt = conn.prepareCall("select user, host from user")
      stmt: java.sql.CallableStatement = com.mysql.jdbc.JDBC4CallableStatement@598b619b: select user, host from user

      But when it is attempted using the MariaDB client, an exception is incorrectly thrown:

      scala> import org.mariadb.jdbc.Driver
      import org.mariadb.jdbc.Driver
       
      scala> import java.sql._
      import java.sql._
       
      scala> val conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql", "root", "***")
      conn: java.sql.Connection = org.mariadb.jdbc.MySQLConnection@3ef84d4c
       
      scala> val stmt = conn.prepareCall("select user, host from user")
      java.sql.SQLSyntaxErrorException: invalid callable syntax
      	at org.mariadb.jdbc.MySQLCallableStatement.<init>(MySQLCallableStatement.java:369)
      	at org.mariadb.jdbc.MySQLConnection.prepareCall(MySQLConnection.java:171)

      In JDBC, the only real difference is that a CallableStatement allows for OUT parameters. However, without foreknowledge of the SQL being prepared, or code to parse and guess which type of SQL string is being passed to the DB-access code, it is desirable to use CallableStatements in place of PreparedStatements for all queries in systems where stored procedures are used.

      Attachments

        Activity

          People

            wlad Vladislav Vaintroub
            dkirk Doug Kirk
            Votes:
            0 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.