yx91490 created HIVE-27397:
------------------------------

             Summary: HivePreparedStatement cannot execute SQL with question 
marks in comments
                 Key: HIVE-27397
                 URL: https://issues.apache.org/jira/browse/HIVE-27397
             Project: Hive
          Issue Type: Bug
    Affects Versions: All Versions
            Reporter: yx91490


It will failed to execute the code snippet:
{code:java}
String sql = "select 1 --?";
try (Connection connection = DriverManager.getConnection(url);
    PreparedStatement stmt = connection.prepareStatement(sql)) {
  try (ResultSet rs = stmt.executeQuery()) {
  }
} {code}
The error message may be like:
{code:java}
Exception in thread "main" java.sql.SQLException: Parameter #1 is unset
    at 
org.apache.hive.jdbc.HivePreparedStatement.updateSql(HivePreparedStatement.java:122)
    at 
org.apache.hive.jdbc.HivePreparedStatement.executeQuery(HivePreparedStatement.java:100)
 {code}
The cause is HivePreparedStatement.splitSqlStatement(sql) take all the template 
sql's chars into consideration including the comments which may be contains the 
question mark unfortunately.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to