Loggin SQL warnings in JDBC driver - Mailing list pgsql-general

From Edson Richter
Subject Loggin SQL warnings in JDBC driver
Date
Msg-id BLU0-SMTP1153C57A744EA6503D03CE3CF130@phx.gbl
Whole thread Raw
List pgsql-general
I've applyied both paths below to be able to print SQL Warnings when
loglevel=1 when working with JDBC 9.2.2 driver.
I did create this as separate driver compilation, because I don't want
the slowdown introduced in the addWarnings (that would affect
significantly my production servers).
Using this patch it is possible to get logged the RAISE NOTICE warnings
from triggers, among other warnings.


First patch:

---------------------------------------------------------------------------------------------------------------------------

# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- <html>AbstractJdbc2Statement.java (<b>Nov 14, 2012 9:08:49
AM</b>)</html>
+++ <html><b>Current File</b></html>
@@ -745,6 +745,10 @@
       */
      public void addWarning(SQLWarning warn)
      {
+      if(connection.getLogger()!=null) {
+        connection.getLogger().log("Warning", warn);
+      }
+
          if (warnings == null) {
              warnings = warn;
              lastWarning = warn;


---------------------------------------------------------------------------------------------------------------------------


Second patch:

---------------------------------------------------------------------------------------------------------------------------

# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- <html>AbstractJdbc2Connection.java (<b>Nov 14, 2012 9:08:49
AM</b>)</html>
+++ <html><b>Current File</b></html>
@@ -327,6 +327,9 @@
       */
      public void addWarning(SQLWarning warn)
      {
+        if(getLogger()!=null) {
+          getLogger().log("Warning", warn);
+        }
          // Add the warning to the chain
          if (firstWarning != null)
              firstWarning.setNextWarning(warn);


---------------------------------------------------------------------------------------------------------------------------


Regards,

Edson


pgsql-general by date:

Previous
From: Kirk Wythers
Date:
Subject: Re: speeding up a join query that utilizes a view
Next
From: "Kevin Grittner"
Date:
Subject: Re: SELECT DISTINCT