pgjdbc/pgjdbc — pull request #210 by tminglei (2014-11-01 13:30:34+00:00)
Title: Allow ResultSet to update with PGobject

Postgres date/time support time zone and microsecond, but java.sql.Date/Time/Timestamp + Calendar can't support them well.

So when mapping java8 time to postgres date/time in [`slick-pg`](https://github.com/tminglei/slick-pg), I used `PGobject` as the delegate, instead of converting java8 time to java.sql.Date/Time/Timestamp then to postgres date/time.

It works well when I use `PreparedStatement` to insert/update records, but when I start to use [`slick`](https://github.com/slick/slick)'s `mutate`, which delegate to ResultSet's update, to update records, I encountered a ClassCastException as below:
```scala
[error] Test com.github.tminglei.slickpg.PgDate2SupportTest.testDatetimeFunctions failed: java.lang.ClassCastException: org.postgresql.util.PGobject cannot be cast to java.sql.Date
[error] at org.postgresql.jdbc2.AbstractJdbc2ResultSet.updateRowBuffer(AbstractJdbc2ResultSet.java:1779)
[error] at org.postgresql.jdbc2.AbstractJdbc2ResultSet.updateRow(AbstractJdbc2ResultSet.java:1391)
[error] at scala.slick.jdbc.MutatingStatementInvoker$$anonfun$mutate$1$$anonfun$apply$mcV$sp$2$$anon$3.row_$eq(StatementInvoker.scala:101)
[error] at com.github.tminglei.slickpg.PgDate2SupportTest$$anonfun$testDatetimeFunctions$1$$anonfun$72.apply(PgDate2SupportTest.scala:196)
[error] at com.github.tminglei.slickpg.PgDate2SupportTest$$anonfun$testDatetimeFunctions$1$$anonfun$72.apply(PgDate2SupportTest.scala:195)
[error] at scala.slick.jdbc.MutatingStatementInvoker$$anonfun$mutate$1$$anonfun$apply$mcV$sp$2.apply(StatementInvoker.scala:117)
[error] at scala.slick.jdbc.MutatingStatementInvoker$$anonfun$mutate$1$$anonfun$apply$mcV$sp$2.apply(StatementInvoker.scala:92)
[error] at scala.util.Either.fold(Either.scala:99)
[error] at scala.slick.jdbc.MutatingStatementInvoker$$anonfun$mutate$1.apply$mcV$sp(StatementInvoker.scala:90)
[error] at scala.slick.jdbc.MutatingStatementInvoker$$anonfun$mutate$1.apply(StatementInvoker.scala:90)
[error] at scala.slick.jdbc.MutatingStatementInvoker$$anonfun$mutate$1.apply(StatementInvoker.scala:90)
[error] at scala.slick.jdbc.JdbcBackend$BaseSession.withTransaction(JdbcBackend.scala:426)
[error] at scala.slick.jdbc.MutatingStatementInvoker$class.mutate(StatementInvoker.scala:87)
[error] at scala.slick.driver.JdbcInvokerComponent$QueryInvoker.mutate(JdbcInvokerComponent.scala:25)
[error] at com.github.tminglei.slickpg.PgDate2SupportTest$$anonfun$testDatetimeFunctions$1.apply(PgDate2SupportTest.scala:195)
[error] at com.github.tminglei.slickpg.PgDate2SupportTest$$anonfun$testDatetimeFunctions$1.apply(PgDate2SupportTest.scala:51)
[error] at scala.slick.backend.DatabaseComponent$DatabaseDef$class.withSession(DatabaseComponent.scala:34)
[error] at scala.slick.jdbc.JdbcBackend$DatabaseFactoryDef$$anon$4.withSession(JdbcBackend.scala:61)
[error] at com.github.tminglei.slickpg.PgDate2SupportTest.testDatetimeFunctions(PgDate2SupportTest.scala:51)
[error] ...
```

The cause is that `pgjdbc` try to cast the PGobject to java.sql.Date/Time/Timestamp when the type is DATE/TIME/TIMESTAMP.

So I send this pull request to allow ResultSet to update with PGobject, which works as expected on my local.

Pls help review and give your suggestions.

Thanks,
Minglei Tu