BUG #15171: JDBC TIMESTAMP WITH TIME ZONE PSQLException When UsingSubstitution Parameter

Поиск
Список
Период
Сортировка
От PG Bug reporting form
Тема BUG #15171: JDBC TIMESTAMP WITH TIME ZONE PSQLException When UsingSubstitution Parameter
Дата
Msg-id 152459274229.19802.17031385353863581472@wrigleys.postgresql.org
обсуждение исходный текст
Ответы Re: BUG #15171: JDBC TIMESTAMP WITH TIME ZONE PSQLException When Using Substitution Parameter  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
The following bug has been logged on the website:

Bug reference:      15171
Logged by:          Len Carlsen
Email address:      len.carlsen@ubc.ca
PostgreSQL version: 9.6.3
Operating system:   x86_64-pc-linux-gnu
Description:

Hello,

I have looked through postgresql.org but can't to seem to find any
references to timestamp bugs so my apologies if this bug is already known.

Executing this query works fine: 'SELECT TIMESTAMP WITH TIME ZONE
'2018-04-17 12:00:00.0-07'"
But executing query "SELECT TIMESTAMP WITH TIME ZONE ?" with a substitution
parameter results in a PSQLException syntax error.

Postgresql 9.6.3 running on Amazon
Postgresql Driver 42.2.2

Exception:
org.postgresql.util.PSQLException: ERROR: syntax error at or near "$1"
  Position: 33
    at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2433)
    at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2178)
    at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:306)
    at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
    at
org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:155)
    at
org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:118)
    at PostgresqlTimestampTest.testTimestamp(PostgresqlTimestampTest.java:51)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

Sample Test:
Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://" + host + ":" + port + "/" + instance;
Connection connection = DriverManager.getConnection(url, user, password);

PreparedStatement stmt2 = connection.prepareStatement("SELECT TIMESTAMP WITH
TIME ZONE ?");
java.sql.Timestamp timestamp = new java.sql.Timestamp((new
Date()).getTime());
stmt2.setTimestamp(1, timestamp);
ResultSet resultSet2 = stmt2.executeQuery();
resultSet2.next();
resultSet2.close();
stmt2.close();
connection.close();

Thanks,

Len


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

Предыдущее
От: PG Bug reporting form
Дата:
Сообщение: BUG #15170: PQtransactionStatus returns ACTIVE after Empty Commit
Следующее
От: jake
Дата:
Сообщение: Re: BUG #15168: "pg_isready -d" effectively ignores given databasename