You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by rv...@apache.org on 2013/04/27 00:35:42 UTC

svn commit: r1476425 - in /jena/Experimental/jena-jdbc/jena-jdbc-core/src/main: java/org/apache/jena/jdbc/connections/JenaConnection.java resources/jena-jdbc-log4j.properties

Author: rvesse
Date: Fri Apr 26 22:35:41 2013
New Revision: 1476425

URL: http://svn.apache.org/r1476425
Log:
Fix logging bug

Modified:
    jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/connections/JenaConnection.java
    jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/resources/jena-jdbc-log4j.properties

Modified: jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/connections/JenaConnection.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/connections/JenaConnection.java?rev=1476425&r1=1476424&r2=1476425&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/connections/JenaConnection.java (original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/connections/JenaConnection.java Fri Apr 26 22:35:41 2013
@@ -76,7 +76,7 @@ import com.hp.hpl.jena.update.UpdateRequ
  * </p>
  */
 public abstract class JenaConnection implements Connection {
-    
+
     private static final Logger LOGGER = LoggerFactory.getLogger(JenaConnection.class);
 
     /**
@@ -213,44 +213,53 @@ public abstract class JenaConnection imp
     public Iterator<CommandPreProcessor> getPreProcessors() {
         return this.preProcessors.iterator();
     }
-    
+
     /**
      * Apply registered pre-processors to the given command text
-     * @param text Command Text
+     * 
+     * @param text
+     *            Command Text
      * @return Command Text after processing by registered pre-processors
      * @throws SQLException
      */
     public String applyPreProcessors(String text) throws SQLException {
         for (CommandPreProcessor preProcessor : this.preProcessors) {
-            if (preProcessor == null) continue;
+            if (preProcessor == null)
+                continue;
             text = preProcessor.preProcessCommandText(text);
         }
         return text;
     }
-    
+
     /**
      * Applies registered pre-processors to the given query
-     * @param q Query
+     * 
+     * @param q
+     *            Query
      * @return Query after processing by registered pre-processors
      * @throws SQLException
      */
     public Query applyPreProcessors(Query q) throws SQLException {
         for (CommandPreProcessor preProcessor : this.preProcessors) {
-            if (preProcessor == null) continue;
+            if (preProcessor == null)
+                continue;
             q = preProcessor.preProcessQuery(q);
         }
         return q;
     }
-    
+
     /**
      * Applies registered pre-processors to the given update
-     * @param u Update
+     * 
+     * @param u
+     *            Update
      * @return Update after processing by registered pre-processors
      * @throws SQLException
      */
     public UpdateRequest applyPreProcessors(UpdateRequest u) throws SQLException {
         for (CommandPreProcessor preProcessor : this.preProcessors) {
-            if (preProcessor == null) continue;
+            if (preProcessor == null)
+                continue;
             u = preProcessor.preProcessUpdate(u);
         }
         return u;
@@ -284,12 +293,14 @@ public abstract class JenaConnection imp
     }
 
     private void closeStatements() throws SQLException {
-        LOGGER.info("Attempting to close " + this.statements.size() + " open statements");
-        for (Statement stmt : this.statements) {
-            stmt.close();
+        if (this.statements.size() > 0) {
+            LOGGER.info("Attempting to close " + this.statements.size() + " open statements");
+            for (Statement stmt : this.statements) {
+                stmt.close();
+            }
+            LOGGER.info("All open statements were closed");
+            this.statements.clear();
         }
-        LOGGER.info("All open statements were closed");
-        this.statements.clear();
     }
 
     protected abstract void closeInternal() throws SQLException;
@@ -298,12 +309,12 @@ public abstract class JenaConnection imp
     public void commit() throws SQLException {
         if (this.isClosed())
             throw new SQLException("Cannot commit on a closed connection");
-        try {            
+        try {
             LOGGER.info("Attempting to commit a transaction...");
-            
+
             // Get the implementation to do the actual commit
             this.commitInternal();
-            
+
             LOGGER.info("Transaction was committed");
 
             // If applicable close cursors
@@ -484,10 +495,10 @@ public abstract class JenaConnection imp
             throw new SQLException("Cannot rollback on a closed connection");
         try {
             LOGGER.info("Attempting to rollback a transaction...");
-            
+
             // Get the implementation to do the actual rollback
             this.rollbackInternal();
-            
+
             LOGGER.info("Transaction was rolled back");
 
             // Close any open statements if applicable
@@ -599,7 +610,7 @@ public abstract class JenaConnection imp
      */
     protected void setWarning(SQLWarning warning) {
         LOGGER.warn(warning.getMessage(), warning);
-        
+
         if (this.warnings == null) {
             this.warnings = warning;
         } else {

Modified: jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/resources/jena-jdbc-log4j.properties
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/resources/jena-jdbc-log4j.properties?rev=1476425&r1=1476424&r2=1476425&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/resources/jena-jdbc-log4j.properties (original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/resources/jena-jdbc-log4j.properties Fri Apr 26 22:35:41 2013
@@ -1,4 +1,4 @@
-log4j.rootLogger=ALL,stdlog,jdbc
+log4j.rootLogger=INFO,stdlog,jdbc
 
 log4j.appender.stdlog=org.apache.log4j.ConsoleAppender
 log4j.appender.stdlog.layout=org.apache.log4j.PatternLayout
@@ -18,5 +18,5 @@ log4j.logger.org.apache.jena=WARN
 log4j.logger.org.apache.jena.riot=INFO
 
 # Jena JDBC log levels
-log4j.logger.org.apache.jena.jdbc=ALL
+log4j.logger.org.apache.jena.jdbc=INFO