Re: timestamp parameter is null
| От | Markus Schaber |
|---|---|
| Тема | Re: timestamp parameter is null |
| Дата | |
| Msg-id | 43E0ECAD.3060609@logix-tt.com обсуждение исходный текст |
| Ответ на | timestamp parameter is null (Papp Márton <papp.marton@assixo.com>) |
| Список | pgsql-jdbc |
Hi, Papp,
Papp Márton wrote:
> 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();
> }
Are you shure that your query is correct?
This would return no rows if you set parameter 1 to null, and the whole
table if you set your parameter to anything not-null.
If you really want to do this, use "select * from tablename where
?::timestamp with time zone is not null"
hth,
schabi
--
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf. | Software Development GIS
Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org
В списке pgsql-jdbc по дате отправления: