Hi am pretty new to jdbi.
I already wrote code to do some insert in a Postgres db without any problem.
Now for the first time I am trying to do a select query. I first wrote it using a ResultSetMapper. But I got an error when running.
I change my code do make it as simple as possible. Even using a jdbc url instead of a datasource, and I still get the same error!
Exception in thread "Thread-1" org.skife.jdbi.v2.exceptions.UnableToExecuteStatementException: org.postgresql.util.PSQLException: ERROR: syntax error at or near "RETURNING"
Position: 33 [statement:"select id, name from subscriber", located:"select id, name from subscriber", rewritten:"select id, name from subscriber", arguments:{ positional:{}, named:{}, finder:[]}]
at org.skife.jdbi.v2.SQLStatement.internalExecute(SQLStatement.java:1364)
at org.skife.jdbi.v2.Query.list(Query.java:78)
at org.skife.jdbi.v2.BasicHandle.select(BasicHandle.java:331)
at com.imetrik.saas.server.insurance.service.datacrunchercontroller.dao.SubscriberDAODbImpl.getSubscriberForDataCruncher(SubscriberDAODbImpl.java:33)
at com.imetrik.saas.server.insurance.service.datacrunchercontroller.DataRequesterTask$1.run(DataRequesterTask.java:72)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "RETURNING"
Position: 33
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:381)
at org.skife.jdbi.v2.SQLStatement.internalExecute(SQLStatement.java:1358)
DBI dbi = new DBI( "jdbc:postgresql://localhost:5432/subdepot", "thierryleveque", "" );
Handle h = dbi.open();
List<Map<String, Object>> rs = h.select("select id, name from subscriber");
It cannot be simpler than that. This sql query is valid. I can use it from any client.