timestamp parameter is null
От | Papp Márton |
---|---|
Тема | timestamp parameter is null |
Дата | |
Msg-id | 43E0DFE1.9020200@assixo.com обсуждение исходный текст |
Ответы |
Re: timestamp parameter is null
Re: timestamp parameter is null |
Список | pgsql-jdbc |
Hello List! I have the following problem: I'm trying to execute a simple SQL query with JDBC and I get an exception, which I don't understand why. Here's the code: public static void main(String[] args) throws Exception { Class.forName("org.postgresql.Driver"); Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5434/dbname", "user", "pass"); PreparedStatement stm = conn.prepareStatement("select * from tablename where ? is not null"); stm.setTimestamp(1, new Timestamp(new Date().getTime())); stm.executeQuery(); } The exception is: Exception in thread "main" org.postgresql.util.PSQLException: ERROR: could not determine data type of parameter $1 at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1512) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1297) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:430) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:346) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:250) at Test6.main(Test6.java:15) The server version is 8.1.0. The Jdbc driver is postgresql-8.1-404.jdbc3.jar. The same code runs fine with the 7.4 jdbc driver. It's also okay, if I'm using any other type than timestamp. Actually, I tried "string" and it worked. I wonder what the problem is. Marci
В списке pgsql-jdbc по дате отправления: