timestamp parameter is null

From: Papp Márton <papp(dot)marton(at)assixo(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: timestamp parameter is null
Date: 2006-02-01 16:20:49
Message-ID: 43E0DFE1.9020200@assixo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Roland Walter 2006-02-01 16:51:25 Re: timestamp parameter is null
Previous Message Senden Kris 2006-02-01 15:45:14 Prepared Statement is not parsed correctly