Hi!

In my work, when I need to use DATE fields, I work with java.sql.Timestamp -
not only with SapDB, but it solves several problems with Oracle, Sybase and
Interbase.

Just do as in following code fragment:

        java.util.Date myDateObject = new java.util.Date( );
        PreparedStatement st = cn.prepareStatement( "insert into table1 (idField,
dateField) values (?, ?)" );
      st.setInt( 1, 100 );
        st.setTimestamp( 2, new java.sql.Timestamp( myDateObject.getTime( ) );
        st.close( );
        cn.close( );

and just be happy!

To get values from ResultSet:

        java.util.Date myDateObject = new java.util.Date( rs.getTimestamp(
"dateField" ).getTime( ) );




Best regards,

Edson Carlos Ericksson Richter
Gerente de Tecnologia
ECONET Solu��es Web
+55 61 326 5115

-----Mensagem original-----
De: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]Em nome de Dag �yvind
Liodden
Enviada em: segunda-feira, 18 de fevereiro de 2002 08:29
Para: SapDB General
Assunto: JDBC and DATE fields



Any hints on how to successfully set date fields in a jdbc prepared
statement? Using java.sql.Date _always_ gives me "value too large".
Changing the fields to a timestamp works, but that's not what I want.

I am not using unicode (that gives me an error message saying "?`
????????"). What implications will using unicode/not using unicode have on
jdbc usage?

Cheers,

Dag

_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to