Browse files

fix: use SQLWarning(String reason) constructor for correct DriverMana… (


* fix: use SQLWarning(String reason) constructor for correct DriverManager logging

Previously, the default constructor was used which only logs "SQLWarning: ", but no information about the warning.
  • Loading branch information...
jamesthomp authored and davecramer committed Apr 4, 2017
1 parent a7e0c83 commit 74a426b929f47a3f585dd6e535300d2ffe77a9da
@@ -13,17 +13,10 @@
private ServerErrorMessage serverError;
public PSQLWarning(ServerErrorMessage err) {
super(err.toString(), err.getSQLState());
this.serverError = err;
public String toString() {
return serverError.toString();
public String getSQLState() {
return serverError.getSQLState();
public String getMessage() {
return serverError.getMessage();
@@ -0,0 +1,37 @@
* Copyright (c) 2016, PostgreSQL Global Development Group
* See the LICENSE file in the project root for more information.
package org.postgresql.util;
import static org.junit.Assert.assertTrue;
import org.postgresql.test.TestUtil;
import org.junit.Test;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class PSQLWarningTest {
public void testPSQLLogsToDriverManagerMessage() throws Exception {
Connection con = TestUtil.openDB();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DriverManager.setLogWriter(new PrintWriter(new OutputStreamWriter(baos, "ASCII")));
Statement stmt = con.createStatement();
stmt.execute("DO language plpgsql $$ BEGIN RAISE NOTICE 'test notice'; END $$;");
assertTrue(baos.toString().contains("NOTICE: test notice"));

1 comment on commit 74a426b


This comment has been minimized.


davecramer commented on 74a426b Apr 4, 2017

So this is failing in travis allegedly with core dumps according to the message. I created another PR #799 just to test this but it doesn't fail. Anyone have any ideas ?

Please sign in to comment.