English 中文(简体)
几位担任职务的近亲准备发言
原标题:Several close placeholders in postgres prepared statement

I m 采用Pop JbdcTemplate with Postgres。

面对灾后复兴开发银行内部准备的声明的麻烦

My query string is:

private static final String SELECT_ALL_PARTIALLY =
            "SELECT login, added FROM admin ORDER BY ? ? OFFSET ? LIMIT ?";

我也想像:

List matches = getJdbcTemplate().query(SELECT_ALL_PARTIALLY,
                (new Object[]{
                    column, // "login" or "added"
                    order,  // "asc" or "desc"
                    offset, 
                    limit
                }),
                new RowMapper() {
                    ...

问题在于<代码>。 页: 1 OFFSET...

org.postgresql.util.PSQLException: ERROR: syntax error at or near "$2"
  Position: 61
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:273)
    at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:648) ...

我怎么能把这两名持不同立场的人分开?

问题回答

邮局允许你将定购指示作为参数。 您需要为<代码>asc和desc的次序设立不同的查询处,并选择其中一人执行。





相关问题
摘录数据

我如何将Excel板的数据输入我的Django应用? I m将PosgreSQL数据库作为数据库。

Postgres dump of only parts of tables for a dev snapshot

On production our database is a few hundred gigabytes in size. For development and testing, we need to create snapshots of this database that are functionally equivalent, but which are only 10 or 20 ...

How to join attributes in sql select statement?

I want to join few attributes in select statement as one for example select id, (name + + surname + + age) as info from users this doesn t work, how to do it? I m using postgreSQL.

What text encoding to use?

I need to setup my PostgreSQL DB s text encoding to handle non-American English characters that you d find showing up in languages such as German, Spanish, and French. What character encoding should ...

SQL LIKE condition to check for integer?

I am using a set of SQL LIKE conditions to go through the alphabet and list all items beginning with the appropriate letter, e.g. to get all books where the title starts with the letter "A": SELECT * ...

热门标签