You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by sd...@apache.org on 2004/02/09 07:33:51 UTC

cvs commit: logging-log4j-sandbox/src/java/org/apache/log4j/jdbc JDBCReceiver.java

sdeboy      2004/02/08 22:33:51

  Modified:    src/java/org/apache/log4j/jdbc JDBCReceiver.java
  Log:
  reuse statement
  
  Revision  Changes    Path
  1.14      +13 -6     logging-log4j-sandbox/src/java/org/apache/log4j/jdbc/JDBCReceiver.java
  
  Index: JDBCReceiver.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j-sandbox/src/java/org/apache/log4j/jdbc/JDBCReceiver.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- JDBCReceiver.java	16 Jan 2004 08:12:06 -0000	1.13
  +++ JDBCReceiver.java	9 Feb 2004 06:33:51 -0000	1.14
  @@ -272,6 +272,11 @@
   
       public void run() {
         ResultSet rs = null;
  +      Statement statement = null;
  +      try {
  +          statement = getConnection().createStatement();
  +      } catch (SQLException se) {se.printStackTrace();return;}
  +
         do {
           try {
             Logger logger = null;
  @@ -288,7 +293,6 @@
             String lineNumber = null;
             Hashtable properties = null;
   
  -          Statement statement = getConnection().createStatement();
             String newSql = sqlStatement;
             if (whereExists) {
             	newSql = newSql + AND_CLAUSE + idField + " > " + lastID;
  @@ -381,15 +385,13 @@
                     doPost(event);
                 }
             }
  - 	      rs.close();
  - 	      rs = null;
           } catch (SQLException se) {
             se.printStackTrace();
           } finally {
   			try {
  -				if (rs != null) {
  -					rs.close();
  -				}
  +    			if (rs != null) {
  +    				rs.close();
  +    			}
   			} catch (SQLException se) {
   			  se.printStackTrace();
   			}
  @@ -402,6 +404,11 @@
             }
           }
         } while (refreshMillis != null);
  +      try {
  +          if (statement != null) {
  +              statement.close();
  +          } 
  +      } catch (SQLException se) {se.printStackTrace();}
         close();
       }
     }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org