我试图使用准备好的语句和TABLE_CATALOG和TABLE_SCHEMA的参数来选择默认模式'PUBLIC'中的所有表。当我创建一个准备好的语句时,我从系统中得到一个错误,这没有任何意义。如果我指定不带TABLE_SCHEMA的TABLE_CATALOG,则可以正常工作。另外,如果我指定不带TABLE_CATALOG的TABLE_SCHEMA,它也可以正常工作。我在这里做错什么了吗?

SELECT
    TABLE_CATALOG,
    TABLE_SCHEMA,
    TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE
    TABLE_CATALOG = ?, TABLE_SCHEMA = ?


线程“主” 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)

最佳答案

这个

TABLE_CATALOG = ?, TABLE_SCHEMA = ?


应该

TABLE_CATALOG = ? AND TABLE_SCHEMA = ?

10-08 13:04