Question
· Dec 1

HELP --- When using JDBC to connect to the Iris , SQL statements containing double quotes cannot be executed.

Hi everyone

   when I use JDBC(Version:intersystems-jdbc-3.8.0.jar) to connect to the Iris(Version: 2021.1.2.338 xDBC Protocol Version 63)

    I’m trying to execute SQL statements that include double quotes, but unfortunately, they’re failing.

For example:

[this query]

         SELECT count(*) AS "_pfgnrtd_0" FROM "BILL_COM_PO"."PrintLog"

[Error ]

     Exception in thread "main" java.sql.SQLException: [SQLCODE: <-1>:<Invalid SQL statement>]
     [Location: <Prepare>]
     [%msg: < IDENTIFIER expected, : found^SELECT COUNT ( * ) AS :%qpar(1) FROM :%qpar>]
        at com.intersystems.jdbc.IRISConnection.getServerError(IRISConnection.java:989)
        at com.intersystems.jdbc.IRISConnection.processError(IRISConnection.java:1134)
        at com.intersystems.jdbc.InStream.readMessageInternal(InStream.java:319)
        at com.intersystems.jdbc.InStream.readMessage(InStream.java:208)
        at com.intersystems.jdbc.InStream.readMessage(InStream.java:183)
        at com.intersystems.jdbc.IRISPreparedStatement.prepareInternal(IRISPreparedStatement.java:589)
        at com.intersystems.jdbc.IRISPreparedStatement.prepare(IRISPreparedStatement.java:550)
        at com.intersystems.jdbc.IRISPreparedStatement.<init>(IRISPreparedStatement.java:25)
        at com.intersystems.jdbc.IRISConnection.getOrCreatePossiblyShardedIRISPreparedStatement(IRISConnection.java:1904)
        at com.intersystems.jdbc.IRISConnection.prepareStatement(IRISConnection.java:1435)
        at com.intersystems.jdbc.IRISConnection.prepareStatement(IRISConnection.java:271)
        at IrisJDBCExample.main(IrisJDBCExample.java:39)

But if it is connected to other versions of iris( Version: 2024.1.0.267.2 xDBC Protocol Version 67), it can execute correctly.

If anyone has encountered a similar issue or has any tips on how to handle double quotes in SQL statements with JDBC, I would really appreciate your insights!

Thanks so much for your help!

Product version: IRIS 2021.2
Discussion (3)4
Log in or sign up to continue