pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Papp Márton <papp.marton@assixo.com>
To: pgsql-jdbc@postgresql.org
Subject: timestamp parameter is null
Date: Wed, 01 Feb 2006 17:20:49 +0100
Message-ID: <43E0DFE1.9020200@assixo.com> (raw)

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




view thread (3+ messages)  latest in thread

Message-ID: <43E0DFE1.9020200@assixo.com>
Permalink:  ../43E0DFE1.9020200@assixo.com/
Also on:    postgresql.org/message-id/43E0DFE1.9020200@assixo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: papp.marton@assixo.com
  Subject: Re: timestamp parameter is null
  In-Reply-To: <43E0DFE1.9020200@assixo.com>
  References: <43E0DFE1.9020200@assixo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox