[CONJ-1034] Issue with escape character + question mark Created: 2022-12-15  Updated: 2022-12-15  Resolved: 2022-12-15

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: 2.2.6
Fix Version/s: 2.4.0

Type: Bug Priority: Major
Reporter: Venkatesh Assignee: Diego Dupin
Resolution: Duplicate Votes: 0
Labels: None
Environment:

Windows 10


Issue Links:
Duplicate
duplicates CONJ-664 SQLException when backslash (\), whic... Closed

 Description   

We are facing the below issue with the insert query execution when we have the backslash at the end of the one columns data and a question mark in the other columns data.

java.sql.SQLException: You need to set exactly 1 parameters on the prepared statement

Example:

Table:

CREATE TABLE `book` (
  `title` varchar(100) DEFAULT NULL,
  `author` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

Java Code:

String query = "INSERT INTO book (author, title) values ('Ghosh\\\\', 'Do You Know?')";
try(PreparedStatement prepareStatement = con.prepareStatement(finalInsertQuery, Statement.RETURN_GENERATED_KEYS);){
prepareStatement.addBatch(); 
prepareStatement.executeBatch(); 
}

Here I am trying to execute the query "INSERT INTO book (author, name) values ('Ghosh\​\​', 'Do You Know?')" from Java. Here the author's name is 'Ghosh\', so am escaping it and title is 'Do You Know?' which has ? mark in the data. Here expectation is that not to consider the '?' as placeholder, but its failing with the error - java.sql.SQLException: You need to set exactly 1 parameters on the prepared statement



 Comments   
Comment by Diego Dupin [ 2022-12-15 ]

this has been corrected with https://jira.mariadb.org/browse/CONJ-664

Generated at Thu Feb 08 03:20:08 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.