Postgres JDBC driver : problem with timestamps.

Поиск
Список
Период
Сортировка
От Vincent Trussart
Тема Postgres JDBC driver : problem with timestamps.
Дата
Msg-id 3947D1F2.B5A931EE@cirano.umontreal.ca
обсуждение исходный текст
Список pgsql-interfaces
Using the JDBC drivers (for 1.2) from the postgresql-7.0.2 rpm
distribution
I cannot read back a timestamp value I just inserted in a column (column
type "timestamp")
with the same application.  This little java code fails :

---------------------------
import java.sql.*;

public class test {
   public static void main(String[] args) throws Exception {
       Class.forName("org.postgresql.Driver").newInstance();       Connection conn =
DriverManager.getConnection("jdbc:postgresql://localhost/test", "test",
"");       PreparedStatement stmt = conn.prepareStatement("insert into test
values (?)");       stmt.setTimestamp(1, new Timestamp(System.currentTimeMillis()));
       stmt.executeUpdate();
       Statement reader = conn.createStatement();       ResultSet rs = reader.executeQuery("select * from test");
while(rs.next()){           System.out.println(rs.getTimestamp(1));       }   }
 
}




Running this code gives :

Exception in thread "main" Bad Timestamp Format at 19 in 2000-06-14
14:32:40.46-04at org.postgresql.jdbc2.ResultSet.getTimestamp(ResultSet.java:447)at test.main(test.java:18)



Any idea?



--
Vincent Trussart
trussarv@cirano.umontreal.ca
Cirano
Québec





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

Предыдущее
От: Bob Kline
Дата:
Сообщение: Re: getMoreResults() returns false incorrectly
Следующее
От: Marius Storm-Olsen
Дата:
Сообщение: Linkerror using ODBC on Solaris 2.6 (Sparc st. 5)