Search Postgresql Archives

Loggin SQL warnings in JDBC driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux