我有以下声明:
PreparedStatement prpStat = conn
.prepareStatement("SELECT * FROM natperson WHERE name LIKE ?");
prpStat.setString(1, "A");
ParameterMetaData pmd = prpStat.getParameterMetaData();
ResultSet rs = prpStat.executeQuery();
当我使用ojdbc7.jar执行prpStat.getParameterMetaData();
方法时,我得到以下内容。使用ojdbc6时不会抛出异常。
java.sql.SQLSyntaxErrorException: ORA-00904: "NAMEIKE": ungültiger Bezeichner
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:392)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:385)
at oracle.jdbc.driver.T4CTTIfun.processError(T4CTTIfun.java:938)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:655)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:249)
at oracle.jdbc.driver.T4C8Odscrarr.doODNY(T4C8Odscrarr.java:96)
at oracle.jdbc.driver.T4CPreparedStatement.doDescribe(T4CPreparedStatement.java:719)
at oracle.jdbc.driver.OracleStatement.describe(OracleStatement.java:4223)
at oracle.jdbc.driver.OracleResultSetMetaData.<init>(OracleResultSetMetaData.java:52)
at oracle.jdbc.driver.OracleStatement.getResultSetMetaData(OracleStatement.java:4206)
at oracle.jdbc.driver.OraclePreparedStatement.getMetaData(OraclePreparedStatement.java:4603)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.getMetaData(OraclePreparedStatementWrapper.java:1510)
at oracle.jdbc.driver.OracleParameterMetaData.getParameterMetaData(OracleParameterMetaData.java:70)
at oracle.jdbc.driver.OraclePreparedStatement.getParameterMetaData(OraclePreparedStatement.java:11621)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.getParameterMetaData(OraclePreparedStatementWrapper.java:1552)
at com.agfa.jdbc.test.JDBCTester.main(JDBCTester.java:45)
任何想法如何解决这个问题?
答案 0 :(得分:6)
Oracle Bug解决了LIKE运算符导致解析器出现问题的问题:
错误18590786
此错误也在类似的Oracle Bug中引用:
错误18644587:ORACLEPARAMETERMETADATAPARSER生成一个联盟的不良声明
尚不清楚该修复程序是否一般可用。
答案 1 :(得分:1)
也许有点太晚了,但是解决这个问题的方法是在LIKE之前用双引号来限定字段:
SELECT * FROM natperson WHERE "NAME" LIKE ?