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

PreparedStatement may not parse ' (') correctly

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.2
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Tested on Windows 7

      Description

      When using preparedStatement, mariadb java client does not parse ' ( ' ) correctly if they are the last chacacter inside a string.

      Simple (non-prepared) Statement and Mysql Connector/J works OK

      The following class reproduces the issue:

      Test.java
      import java.sql.*;
      
      public class MariaDBTest {
      	static Connection con;
      	
      	public static void main(String[] args) throws Exception {
      		Class.forName("org.mariadb.jdbc.Driver");
      		//Class.forName("com.mysql.jdbc.Driver");
      		String dbUrl = "jdbc:mysql://localhost:3306/";
      		con = DriverManager.getConnection(dbUrl, "root", "root");
      		System.out.println("Connected to " + dbUrl);
      		
      		exec("CREATE DATABASE IF NOT EXISTS test");
      		exec("USE test");
      		exec("DROP TABLE IF EXISTS `test1`");
      		exec("CREATE TABLE `test1` (`col1` varchar(50))");
      		exec("INSERT INTO `test1` VALUES ('\\'a')"); //works
      		exec("INSERT INTO `test1` VALUES ('\\'')");  //does not works
      
      		con.close();
      		System.out.println("Exiting with no errors");
      	}
      	
      	static void exec(String sql) throws SQLException {
      		System.out.println("sql: "+sql);
      		// error occurs only with prepared statement 
      		//con.createStatement().executeUpdate(sql);
      		con.prepareStatement(sql).executeUpdate();
      	}
      }
      

        Gliffy Diagrams

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              wlad Vladislav Vaintroub
              Reporter:
              tbrugz Telmo Brugnara
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 20 minutes
                20m