Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The server's DateStyle parameter was changed to ISO. The JDBC driver requires DateStyle to begin with ISO for correct operation #1080

Closed
afarber opened this issue Jan 20, 2018 · 0 comments · Fixed by #1081
Milestone

Comments

@afarber
Copy link

afarber commented Jan 20, 2018

Hello and thank you for developing this software.

There seems to be a bug in the version 42.2.0.jre7 though:

I use Jetty 9.4.7 on CentOS 7.4 with PostgreSQL 9.6.6 with pgbouncer and postgresql-jdbc-4.2.0:

# rpm -qa | grep postgr
postgresql96-server-9.6.6-1PGDG.rhel7.x86_64
postgresql-jdbc-javadoc-42.2.0-1.rhel7.noarch
postgresql96-libs-9.6.6-1PGDG.rhel7.x86_64
postgresql96-devel-9.6.6-1PGDG.rhel7.x86_64
postgresql-libs-9.2.23-3.el7_4.x86_64
postgresql-jdbc-42.2.0-1.rhel7.noarch
postgresql96-9.6.6-1PGDG.rhel7.x86_64

I run a WAR file in Jetty, compiled as following:

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <jetty.version>9.4.7.v20170914</jetty.version>
        <pgsql.version>42.1.4.jre7</pgsql.version>
    </properties>

When I change the last line to <pgsql.version>42.2.0.jre7</pgsql.version> and recompile my WAR-file, then the Java code -

String SQL_MERGE_USERS = "SELECT words_merge_users(?::jsonb, ?::inet, ?::text, ?::text, ?::text)";

// the next line in MyListener.java throws the exception

try (Connection db = DriverManager.getConnection(DATABASE_URL, DATABASE_USER, DATABASE_PASS);
        PreparedStatement st = db.prepareStatement(SQL_MERGE_USERS)) {
    st.setString(1, users);
    st.setString(2, ip);
    st.setString(3, fcm);
    st.setString(4, apns);
    st.setString(5, adm);
    ResultSet rs = st.executeQuery();

throws an exception:

WARNING: SQLException occurred while connecting to 127.0.0.1:6432
org.postgresql.util.PSQLException: The server's DateStyle parameter was changed to ISO. The JDBC driver requires DateStyle to begin with ISO for correct operation.
at org.postgresql.core.v3.QueryExecutorImpl.receiveParameterStatus(QueryExecutorImpl.java:2603)
at org.postgresql.core.v3.QueryExecutorImpl.readStartupMessages(QueryExecutorImpl.java:2569)
at org.postgresql.core.v3.QueryExecutorImpl.<init>(QueryExecutorImpl.java:131)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:212)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195)
at org.postgresql.Driver.makeConnection(Driver.java:452)
at org.postgresql.Driver.connect(Driver.java:254)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at de.slova.websockets.MyListener.mergeUsers(MyListener.java:152)
at de.slova.websockets.MyListener.handleLogin(MyListener.java:208)
at de.slova.websockets.MyListener.onWebSocketText(MyListener.java:83)
at org.eclipse.jetty.websocket.common.events.JettyListenerEventDriver.onTextMessage(JettyListenerEventDriver.java:189)
at org.eclipse.jetty.websocket.common.message.SimpleTextMessage.messageComplete(SimpleTextMessage.java:69)
at org.eclipse.jetty.websocket.common.events.AbstractEventDriver.appendMessage(AbstractEventDriver.java:66)
at org.eclipse.jetty.websocket.common.events.JettyListenerEventDriver.onTextFrame(JettyListenerEventDriver.java:158)
at org.eclipse.jetty.websocket.common.events.AbstractEventDriver.incomingFrame(AbstractEventDriver.java:162)
at org.eclipse.jetty.websocket.common.WebSocketSession.incomingFrame(WebSocketSession.java:375)
at org.eclipse.jetty.websocket.common.extensions.AbstractExtension.nextIncomingFrame(AbstractExtension.java:182)
at org.eclipse.jetty.websocket.common.extensions.compress.PerMessageDeflateExtension.nextIncomingFrame(PerMessageDeflateExtension.java:105)
at org.eclipse.jetty.websocket.common.extensions.compress.CompressExtension.forwardIncoming(CompressExtension.java:142)
at org.eclipse.jetty.websocket.common.extensions.compress.PerMessageDeflateExtension.incomingFrame(PerMessageDeflateExtension.java:85)
at org.eclipse.jetty.websocket.common.extensions.ExtensionStack.incomingFrame(ExtensionStack.java:220)
at org.eclipse.jetty.websocket.common.Parser.notifyFrame(Parser.java:220)
at org.eclipse.jetty.websocket.common.Parser.parse(Parser.java:256)
at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.readParse(AbstractWebSocketConnection.java:679)
at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.onFillable(AbstractWebSocketConnection.java:511)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
at java.lang.Thread.run(Thread.java:745)

However I do have datestyle setting in my postgresql.conf:

datestyle = 'iso, mdy'

and I can see it at the console:

# psql
psql (9.6.6)
Type "help" for help.

words=> show datestyle;
 DateStyle 
-----------
 ISO, MDY
(1 row)

I.e. my datestyle setting (unchanged from stock installation) does begin with "ISO" as the exception wants it too.

vlsi added a commit to vlsi/pgjdbc that referenced this issue Jan 20, 2018
Default PostgreSQL configuration is DateStyle='iso, dmy',
however just iso would be fine.

Note: PostgreSQL prints DateStyle value in upper case, and toUpperCase
was added just in case.

fixes pgjdbc#1080
@vlsi vlsi modified the milestones: 42.3.0, 42.2.1 Jan 20, 2018
vlsi added a commit that referenced this issue Jan 21, 2018
Default PostgreSQL configuration is DateStyle='iso, dmy', however pgjdbc should not raise errors
if DateStyle is just ISO

Note: PostgreSQL prints DateStyle value in upper case, and toUpperCase
was added just in case.

fixes #1080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants