Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- scala> Class.forName("org.postgresql.Driver")
- res0: Class[_] = class org.postgresql.Driver
- scala> val props = new java.util.Properties
- props: java.util.Properties = {}
- scala> props.setProperty("user","vagrant")
- res1: Object = null
- scala> props.setProperty("password","vagrant")
- res2: Object = null
- scala> props.setProperty("statement_timeout", "1")
- res4: Object = null
- scala> props
- res5: java.util.Properties = {statement_timeout=1, user=vagrant, password=vagrant}
- scala> java.sql.DriverManager.getConnection("jdbc:postgresql://localhost/vagrant", props)
- res6: java.sql.Connection = org.postgresql.jdbc4.Jdbc4Connection@32eb8dc1
- scala> implicit val c: java.sql.Connection = res6
- c: java.sql.Connection = org.postgresql.jdbc4.Jdbc4Connection@32eb8dc1
- scala> anorm.SQL("select count(*) from foo")().toList
- res8: List[anorm.Row] = List(Row(ColumnName(.count,Some(count)): 8749099 as java.lang.Long))
- scala> anorm.SQL("set statement_timeout = 1").execute()
- res11: Boolean = false
- scala> anorm.SQL("select count(*) from foo")().toList
- org.postgresql.util.PSQLException: ERROR: canceling statement due to statement timeout
- at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2270)
- at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1998)
- at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
- at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:570)
- at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:420)
- at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:305)
- at anorm.Sql$class.resultSet(Anorm.scala:286)
- at anorm.SqlQuery.resultSet(Anorm.scala:384)
- at anorm.Sql$class.apply(Anorm.scala:281)
- at anorm.SqlQuery.apply(Anorm.scala:384)
- ... 43 elided
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement