我正在尝试选择默认架构中的所有表格,' PUBLIC'使用TABLE_CATALOG和TABLE_SCHEMA的预准备语句和参数。当我创建一个准备好的语句时,我从系统中得到一个错误,它没有任何意义。如果我在没有TABLE_SCHEMA的情况下指定TABLE_CATALOG,它可以完美地工作。另外,如果我在没有TABLE_CATALOG的情况下指定TABLE_SCHEMA,它也可以正常工作。我在这里做错了吗?
SELECT
TABLE_CATALOG,
TABLE_SCHEMA,
TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_CATALOG = ?, TABLE_SCHEMA = ?
线程中的异常" main" org.h2.jdbc.JdbcSQLException:SQL中的语法错误
statement "SELECT
TABLE_CATALOG,
TABLE_SCHEMA,
TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_CATALOG = ?,[*] TABLE_SCHEMA = ?"; SQL statement:
SELECT
TABLE_CATALOG,
TABLE_SCHEMA,
TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_CATALOG = ?, TABLE_SCHEMA = ? [42000-193]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException.get(DbException.java:155)
at org.h2.message.DbException.getSyntaxError(DbException.java:191)
at org.h2.command.Parser.getSyntaxError(Parser.java:530)
at org.h2.command.Parser.prepareCommand(Parser.java:257)
at org.h2.engine.Session.prepareLocal(Session.java:561)
at org.h2.engine.Session.prepareCommand(Session.java:502)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1203)
at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:73)
at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:287)
at com.zaxxer.hikari.pool.ProxyConnection.prepareStatement(ProxyConnection.java:310)
at com.zaxxer.hikari.pool.HikariProxyConnection.prepareStatement(HikariProxyConnection.java)
答案 0 :(得分:2)
此
TABLE_CATALOG = ?, TABLE_SCHEMA = ?
应该是
TABLE_CATALOG = ? AND TABLE_SCHEMA = ?