Re: CallableStatement.setTimestamp bug

Поиск
Список
Период
Сортировка
От Dave Cramer
Тема Re: CallableStatement.setTimestamp bug
Дата
Msg-id 472CE30E-942E-4C52-925E-F24E5D56AE42@fastcrypt.com
обсуждение исходный текст
Ответ на CallableStatement.setTimestamp bug  (Reuben Pasquini <pasquinir@bellsouth.net>)
Список pgsql-jdbc
Reuben,

Didn't see this coming, problem is we have two timestamp types and
java only has one. We attempted to get around this by letting the
server do auto type casting. It appears this doesnt' work with
functions. I think it might be possible to work around this in
callable statements, but we still have to figure out which type to
send timestamptz, or timestamp

Dave

On 14-Nov-06, at 11:05 PM, Reuben Pasquini wrote:

> Hello!
>
> It appears that CallableStatement.setTimestamp()
> does not work correctly with the latest 8.1 jdbc driver -
> I've listed a test case below -
> sorry if this bug is already known.
> Let me know if you have any questions.
> Thanks for all the great work.
>
> Reuben
>
> --------------------
>
> p-nut:/tmp pasquini$ javac Frick.java
>
> p-nut:/tmp pasquini$ java -cp postgresql-8.1-407.jdbc3.jar:. Frick
> Nov 14, 2006 9:59:54 PM Frick main
> INFO: Caught: org.postgresql.util.PSQLException: ERROR: function
> donothing("unknown") does not exist
>
>
> p-nut:/tmp pasquini$ cat Frick.java
> import java.util.*;
> import java.util.logging.Logger;
> import java.util.logging.Level;
> import java.lang.reflect.*;
> import java.sql.*;
>
> /* .............
> CREATE OR REPLACE FUNCTION doNothing ( TIMESTAMP )
>   RETURNS INTEGER AS $FUNC$
>         BEGIN
>             RETURN 0;
>         END; $FUNC$
> LANGUAGE plpgsql;
> */
>
> /**
> * Test postgres JDBC setTimestamp functionality against doNothing()
> */
> public class Frick {
>
>     public static void main ( String[] v_argv ) {
>         Logger log_generic = Logger.getLogger ( "littleware" );
>
>         try {
>             Class.forName ( "org.postgresql.Driver" );
>             Connection sql_conn = DriverManager.getConnection
> ( "jdbc:postgresql:littleware://localhost:5432", "littleware_user",
> "" );
>             CallableStatement sql_call = sql_conn.prepareCall
> ( "{ ? = call doNothing ( ? ) }" );
>             java.util.Date  t_now = new java.util.Date ();
>             sql_call.registerOutParameter ( 1, Types.INTEGER );
>             sql_call.setTimestamp ( 2, new Timestamp
> ( t_now.getTime () ) );
>             sql_call.execute ();
>         } catch ( Exception e ) {
>             log_generic.log ( Level.INFO, "Caught: " + e );
>         }
>     }
> }
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 6: explain analyze is your friend
>


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Håkan Jacobsson
Дата:
Сообщение: Re: Need help with org.postgresql.util.PSQLException: An I/O error occured while
Следующее
От: Mark Lewis
Дата:
Сообщение: Re: CallableStatement.setTimestamp bug