Guest User

Untitled

a guest
Jul 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. protected static final String AUTH_QUERY = "SELECT "SECRET" FROM "user" WHERE "NAME" = :name";
  2.  
  3. String password = sql2o.open().createQuery(AUTH_QUERY).addParameter("name", username).executeScalar(String.class);
  4.  
  5. org.postgresql.util.PSQLException: ERROR: syntax error at or near "RETURNING"
  6. Position: 47
  7. at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2161)
  8. at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1890)
  9. at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
  10. at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:559)
  11. at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417)
  12. at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:302)
  13. at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
  14. at org.sql2o.Query.executeScalar(Query.java:533)
  15. at org.sql2o.Query.executeScalar(Query.java:577)
  16. at org.sql2o.Query.executeScalar(Query.java:568)
  17.  
  18. <Configure id="wac" class="org.eclipse.jetty.webapp.WebAppContext">
  19.  
  20. <New id="mydb" class="org.eclipse.jetty.plus.jndi.Resource">
  21. <Arg></Arg>
  22. <Arg>jdbc/mydb</Arg>
  23. <Arg>
  24. <New class="com.mchange.v2.c3p0.ComboPooledDataSource">
  25. <Set name="driverClass">org.postgresql.Driver</Set>
  26. <Set name="jdbcUrl">jdbc:postgresql://localhost:5432/mydb</Set>
  27. <Set name="user">user</Set>
  28. <Set name="password">pass</Set>
  29. </New>
  30. </Arg>
  31. </New>
  32. </Configure>
  33.  
  34. <dependency>
  35. <groupId>org.postgresql</groupId>
  36. <artifactId>postgresql</artifactId>
  37. <version>9.3-1101-jdbc41</version>
  38. </dependency>
  39.  
  40. No. Time Source Destination Protocol Length Info
  41. 12 0.175636000 127.0.0.1 127.0.0.1 PGSQL 182 >P/B/D/E/S
  42.  
  43. Frame 12: 182 bytes on wire (1456 bits), 182 bytes captured (1456 bits) on interface 0
  44. PostgreSQL
  45. Type: Parse
  46. Length: 69
  47. Statement:
  48. Query: SELECT "SECRET" FROM "user" WHERE "NAME" = $1 RETURNING *
  49. Parameters: 1
  50. Type OID: 1043
  51.  
  52. String sql = "INSERT INTO testTable(var1, var2) values ("1","2"), ("1","2") RETURNING id;--";
  53.  
  54. PreparedStatement ps = getConnection().prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
  55. ps.executeUpdate();
  56. ResultSet rs = ps.getGeneratedKeys();
Add Comment
Please, Sign In to add comment