将ojdbc驱动程序升级到ojdbc7后,camel-sql组件在使用命名参数执行查询时开始创建问题。
提供了在执行期间失败的简单SQL查询。并非所有查询都失败,但只有少数失败。
SELECT some_id FROM app_schema.app_store_table WHERE store_id =:#storeId and source =:#source;
在数据库端验证用户名可以通过app_schema访问该对象,并尝试创建PUBLIC同义词,但没有运气。
根据我的理解,它在尝试获取SqlProducer.java中的参数计数时失败 - > process() - > execute() - > ps.getParameterMetaData()
jdbcTemplate.execute(statementCreator, new PreparedStatementCallback<Map<?, ?>>() {
public Map<?, ?> doInPreparedStatement(PreparedStatement ps) throws SQLException {
int expected = parametersCount > 0 ? parametersCount : ps.getParameterMetaData().getParameterCount();
进一步调试从ojdbc7驱动程序中发现以下错误。它确认ojdbc7驱动程序无法正确解析查询。在下面的示例中,schema_name和table_name之间的。[DOT]在执行之前被ojdbc驱动程序替换。
Aug 30, 2017 9:06:57 AM oracle.jdbc.driver.OracleConnection isValid
FINE: 19C71BE Exit [17.696372ms]
Aug 30, 2017 9:06:57 AM oracle.jdbc.driver.PhysicalConnection prepareStatement
FINE: 19C71BE Public Enter: "**SELECT some_id FROM app_schema.app_store_table WHERE store_id = ? and source = ?**"
Aug 30, 2017 9:06:57 AM oracle.jdbc.driver.PhysicalConnection prepareStatement
FINE: 19C71BE Return: oracle.jdbc.driver.OraclePreparedStatementWrapper@c2c269
Aug 30, 2017 9:06:57 AM oracle.jdbc.driver.PhysicalConnection prepareStatement
FINE: 19C71BE Exit [226.482362ms]
Aug 30, 2017 9:06:57 AM oracle.jdbc.driver.PhysicalConnection prepareStatement
FINE: 19C71BE Public Enter: "***SELECT store_id, source FROM app_schemaapp_store_table***" <-- .[DOT] between schema_name and table_name is replaced by the driver which results in this error.
Aug 30, 2017 9:06:57 AM oracle.jdbc.driver.PhysicalConnection prepareStatement
FINE: 19C71BE Return: oracle.jdbc.driver.OraclePreparedStatementWrapper@e1e592
Aug 30, 2017 9:06:57 AM oracle.jdbc.driver.PhysicalConnection prepareStatement
FINE: 19C71BE Exit [0.413825ms]
Aug 30, 2017 9:06:57 AM oracle.jdbc.driver.OraclePreparedStatement getMetaData
FINE: E1E592 Public Enter:
Aug 30, 2017 9:06:57 AM oracle.jdbc.driver.T4CTTIoer processError
SEVERE: CD5A42 Throwing SQLException: ORA-00942: table or view does not exist
使用以下命令
可以轻松复制-- example for .[DOT] getting replaced between schema_name and table_name. Refer Parameter SQL.
C:\Users\xxxxxx\Desktop\ojdbc\oracle>java -cp ojdbc7_g-12.1.0.2.jar oracle.jdbc.driver.OracleParameterMetaDataParser "*SELECT some_id FROM app_schema.app_store_table WHERE store_id = ? and source = ?*"
SQL:SELECT some_id FROM app_schema.app_store_table WHERE store_id = :1 and source = :2
SqlKind:SELECT, Parameter Count=2
Parameter SQL: ***SELECT store_id, source FROM app_schemaapp_store_table***
-- example for invalid parsing of the query. Refer Parameter SQL.
C:\Users\vm\ojdbc\oracle>java -cp ojdbc7_g-12.1.0.2.jar oracle.jdbc.driver.OracleParameterMetaDataParser "*SELECT f_some_id FROM app_store_table WHERE f_store_id = ? and f_source = ?*"
SQL:SELECT f_some_id FROM app_store_table WHERE f_store_id = :1 and f_source = :2
SqlKind:SELECT, Parameter Count=2
Parameter SQL: ***SELECT f, f FROM app_store_table***
异常。
Caused by: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
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:1018)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:522)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:257)
at oracle.jdbc.driver.T4C8Odscrarr.doODNY(T4C8Odscrarr.java:96)
at oracle.jdbc.driver.T4CPreparedStatement.doDescribe(T4CPreparedStatement.java:717)
at oracle.jdbc.driver.OracleStatement.describe(OracleStatement.java:4404)
at oracle.jdbc.driver.OracleResultSetMetaData.<init>(OracleResultSetMetaData.java:52)
at oracle.jdbc.driver.OracleStatement.getResultSetMetaData(OracleStatement.java:4387)
at oracle.jdbc.driver.OraclePreparedStatement.getMetaData(OraclePreparedStatement.java:5581)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.getMetaData(OraclePreparedStatementWrapper.java:1509)
at oracle.jdbc.driver.OracleParameterMetaData.getParameterMetaData(OracleParameterMetaData.java:70)
at oracle.jdbc.driver.OraclePreparedStatement.getParameterMetaData(OraclePreparedStatement.java:12861)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.getParameterMetaData(OraclePreparedStatementWrapper.java:1551)
at org.apache.commons.dbcp2.DelegatingPreparedStatement.getParameterMetaData(DelegatingPreparedStatement.java:266)
at org.apache.commons.dbcp2.DelegatingPreparedStatement.getParameterMetaData(DelegatingPreparedStatement.java:266)
at org.apache.camel.component.sql.SqlProducer$2.doInPreparedStatement(SqlProducer.java:92)
at org.apache.camel.component.sql.SqlProducer$2.doInPreparedStatement(SqlProducer.java:90)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:589)
... 29 more
相同的组件与ojdbc6配合良好。
环境详情:
-Camel : 2.15.1.redhat-621166
-Fuse : 6.2.1
-OJDBC : ojdbc7 (12.1.0.2)
-commons-dbcp2 (2.1.1)
-commons-pool2 (2.4.2)
-spring-jdbc (3.2.12.RELEASE)