[ 
https://issues.apache.org/jira/browse/HIVE-27397?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17728331#comment-17728331
 ] 

yx91490 commented on HIVE-27397:
--------------------------------

the most suitable solution maybe move the parameter substitute process to 
server side, thus sql parser can remove the comments safely, but it's a big 
change.

> 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
>            Priority: Major
>
> 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