亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? jdbcappender.java

?? log4j的源碼
?? JAVA
字號:
/* * Copyright 1999-2005 The Apache Software Foundation. *  * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at *  *      http://www.apache.org/licenses/LICENSE-2.0 *  * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.log4j.jdbc;import org.apache.log4j.*;import org.apache.log4j.spi.*;import org.apache.log4j.PatternLayout;import java.util.ArrayList;import java.util.Iterator;import java.sql.DriverManager;import java.sql.Connection;import java.sql.Statement;import java.sql.SQLException;/**  <p><b><font color="#FF2222">WARNING: This version of JDBCAppender  is very likely to be completely replaced in the future. Moreoever,  it does not log exceptions</font></b>.  The JDBCAppender provides for sending log events to a database.      <p>Each append call adds to an <code>ArrayList</code> buffer.  When  the buffer is filled each log event is placed in a sql statement  (configurable) and executed.  <b>BufferSize</b>, <b>db URL</b>, <b>User</b>, & <b>Password</b> are  configurable options in the standard log4j ways.  <p>The <code>setSql(String sql)</code> sets the SQL statement to be  used for logging -- this statement is sent to a  <code>PatternLayout</code> (either created automaticly by the  appender or added by the user).  Therefore by default all the  conversion patterns in <code>PatternLayout</code> can be used  inside of the statement.  (see the test cases for examples)  <p>Overriding the {@link #getLogStatement} method allows more  explicit control of the statement used for logging.  <p>For use as a base class:    <ul>    <li>Override <code>getConnection()</code> to pass any connection    you want.  Typically this is used to enable application wide    connection pooling.     <li>Override <code>closeConnection(Connection con)</code> -- if     you override getConnection make sure to implement     <code>closeConnection</code> to handle the connection you     generated.  Typically this would return the connection to the     pool it came from.     <li>Override <code>getLogStatement(LoggingEvent event)</code> to     produce specialized or dynamic statements. The default uses the     sql option value.    </ul>    @author Kevin Steppe (<A HREF="mailto:ksteppe@pacbell.net">ksteppe@pacbell.net</A>)*/public class JDBCAppender extends org.apache.log4j.AppenderSkeleton    implements org.apache.log4j.Appender {  /**   * URL of the DB for default connection handling   */  protected String databaseURL = "jdbc:odbc:myDB";  /**   * User to connect as for default connection handling   */  protected String databaseUser = "me";  /**   * User to use for default connection handling   */  protected String databasePassword = "mypassword";  /**   * Connection used by default.  The connection is opened the first time it   * is needed and then held open until the appender is closed (usually at   * garbage collection).  This behavior is best modified by creating a   * sub-class and overriding the <code>getConnection</code> and   * <code>closeConnection</code> methods.   */  protected Connection connection = null;  /**   * Stores the string given to the pattern layout for conversion into a SQL   * statement, eg: insert into LogTable (Thread, Class, Message) values   * ("%t", "%c", "%m").   *   * Be careful of quotes in your messages!   *   * Also see PatternLayout.   */  protected String sqlStatement = "";  /**   * size of LoggingEvent buffer before writting to the database.   * Default is 1.   */  protected int bufferSize = 1;  /**   * ArrayList holding the buffer of Logging Events.   */  protected ArrayList buffer;  /**   * Helper object for clearing out the buffer   */  protected ArrayList removes;  public JDBCAppender() {    super();    buffer = new ArrayList(bufferSize);    removes = new ArrayList(bufferSize);  }  /**   * Adds the event to the buffer.  When full the buffer is flushed.   */  public void append(LoggingEvent event) {    buffer.add(event);    if (buffer.size() >= bufferSize)      flushBuffer();  }  /**   * By default getLogStatement sends the event to the required Layout object.   * The layout will format the given pattern into a workable SQL string.   *   * Overriding this provides direct access to the LoggingEvent   * when constructing the logging statement.   *   */  protected String getLogStatement(LoggingEvent event) {    return getLayout().format(event);  }  /**   *   * Override this to provide an alertnate method of getting   * connections (such as caching).  One method to fix this is to open   * connections at the start of flushBuffer() and close them at the   * end.  I use a connection pool outside of JDBCAppender which is   * accessed in an override of this method.   * */  protected void execute(String sql) throws SQLException {    Connection con = null;    Statement stmt = null;    try {        con = getConnection();        stmt = con.createStatement();        stmt.executeUpdate(sql);    } catch (SQLException e) {       if (stmt != null)	     stmt.close();       throw e;    }    stmt.close();    closeConnection(con);    //System.out.println("Execute: " + sql);  }  /**   * Override this to return the connection to a pool, or to clean up the   * resource.   *   * The default behavior holds a single connection open until the appender   * is closed (typically when garbage collected).   */  protected void closeConnection(Connection con) {  }  /**   * Override this to link with your connection pooling system.   *   * By default this creates a single connection which is held open   * until the object is garbage collected.   */  protected Connection getConnection() throws SQLException {      if (!DriverManager.getDrivers().hasMoreElements())	     setDriver("sun.jdbc.odbc.JdbcOdbcDriver");      if (connection == null) {        connection = DriverManager.getConnection(databaseURL, databaseUser,					databasePassword);      }      return connection;  }  /**   * Closes the appender, flushing the buffer first then closing the default   * connection if it is open.   */  public void close()  {    flushBuffer();    try {      if (connection != null && !connection.isClosed())          connection.close();    } catch (SQLException e) {        errorHandler.error("Error closing connection", e, ErrorCode.GENERIC_FAILURE);    }    this.closed = true;  }  /**   * loops through the buffer of LoggingEvents, gets a   * sql string from getLogStatement() and sends it to execute().   * Errors are sent to the errorHandler.   *   * If a statement fails the LoggingEvent stays in the buffer!   */  public void flushBuffer() {    //Do the actual logging    removes.ensureCapacity(buffer.size());    for (Iterator i = buffer.iterator(); i.hasNext();) {      try {        LoggingEvent logEvent = (LoggingEvent)i.next();	    String sql = getLogStatement(logEvent);	    execute(sql);        removes.add(logEvent);      }      catch (SQLException e) {	    errorHandler.error("Failed to excute sql", e,			   ErrorCode.FLUSH_FAILURE);      }    }        // remove from the buffer any events that were reported    buffer.removeAll(removes);        // clear the buffer of reported events    removes.clear();  }  /** closes the appender before disposal */  public void finalize() {    close();  }  /**   * JDBCAppender requires a layout.   * */  public boolean requiresLayout() {    return true;  }  /**   *   */  public void setSql(String s) {    sqlStatement = s;    if (getLayout() == null) {        this.setLayout(new PatternLayout(s));    }    else {        ((PatternLayout)getLayout()).setConversionPattern(s);    }  }  /**   * Returns pre-formated statement eg: insert into LogTable (msg) values ("%m")   */  public String getSql() {    return sqlStatement;  }  public void setUser(String user) {    databaseUser = user;  }  public void setURL(String url) {    databaseURL = url;  }  public void setPassword(String password) {    databasePassword = password;  }  public void setBufferSize(int newBufferSize) {    bufferSize = newBufferSize;    buffer.ensureCapacity(bufferSize);    removes.ensureCapacity(bufferSize);  }  public String getUser() {    return databaseUser;  }  public String getURL() {    return databaseURL;  }  public String getPassword() {    return databasePassword;  }  public int getBufferSize() {    return bufferSize;  }  /**   * Ensures that the given driver class has been loaded for sql connection   * creation.   */  public void setDriver(String driverClass) {    try {      Class.forName(driverClass);    } catch (Exception e) {      errorHandler.error("Failed to load driver", e,			 ErrorCode.GENERIC_FAILURE);    }  }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美xxx久久| 亚洲激情图片小说视频| 欧美在线免费观看亚洲| 91亚洲精品一区二区乱码| 成人高清av在线| 99re这里只有精品首页| 色综合久久久网| 欧美午夜精品免费| 欧美一区二区视频在线观看| 日韩亚洲欧美一区| 久久亚洲综合色一区二区三区| 久久久一区二区三区| 国产精品国产精品国产专区不蜜 | 国产一区二区伦理| 国产精品一二三区在线| 91欧美一区二区| 国产日韩精品一区| 一区二区视频在线看| 夜夜嗨av一区二区三区中文字幕| 国产精品资源在线| 精品国产污污免费网站入口| 中文字幕巨乱亚洲| 天天色天天爱天天射综合| 国产一区二区免费看| 日韩免费电影网站| 亚洲欧美日韩电影| 激情综合五月天| 一本久道久久综合中文字幕| 国产精品美女久久久久久2018| 亚洲国产aⅴ成人精品无吗| 国产一区二区三区在线观看免费视频 | 国产成人av在线影院| 色呦呦一区二区三区| 中文字幕一区二区三区不卡在线| 天堂在线一区二区| 成人禁用看黄a在线| 中文字幕免费一区| 色又黄又爽网站www久久| 亚洲精品国产无套在线观| 91视频一区二区三区| 一区二区在线观看不卡| 欧美日韩第一区日日骚| 亚洲乱码国产乱码精品精可以看| 91丝袜美腿高跟国产极品老师| 亚洲已满18点击进入久久| 国产不卡一区视频| 欧美v国产在线一区二区三区| 久久99国产精品久久| 久久精品一区二区三区不卡 | 亚洲人成网站精品片在线观看| 99久久精品情趣| 一区二区三区国产精品| 91精品国产一区二区三区蜜臀 | wwwwxxxxx欧美| 国产999精品久久| 自拍偷自拍亚洲精品播放| 国产麻豆视频精品| 亚洲素人一区二区| 欧美日韩中文字幕精品| 亚洲另类色综合网站| 欧美喷潮久久久xxxxx| 韩国在线一区二区| 日韩欧美中文字幕公布| 国产精品18久久久久久久久久久久| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 亚洲精品中文在线观看| 欧美亚洲国产怡红院影院| 美女视频网站黄色亚洲| 欧美日韩1区2区| 国产原创一区二区| 一区二区三区免费| 久久综合九色欧美综合狠狠 | 国产成人在线视频网址| 亚洲少妇中出一区| 欧美α欧美αv大片| 91麻豆6部合集magnet| 经典三级一区二区| 一区二区三区不卡视频 | 亚洲资源在线观看| 精品国产乱子伦一区| 在线观看av一区| 国产馆精品极品| 午夜久久久影院| 综合激情成人伊人| 国产网站一区二区| 91精品国产高清一区二区三区 | 精品久久久久99| 欧美日韩一二三| 成人爱爱电影网址| 国产一区在线视频| 日韩主播视频在线| 亚洲一区二区视频在线观看| 久久九九久久九九| 精品欧美一区二区久久| 欧美午夜精品免费| 色哟哟日韩精品| 波多野结衣亚洲一区| 亚洲影视在线播放| 亚洲欧美自拍偷拍| 国产欧美1区2区3区| 久久精品亚洲一区二区三区浴池| 91精品国产91久久久久久最新毛片| 91亚洲精品久久久蜜桃| 99国产精品久久久| 成a人片亚洲日本久久| 成人免费视频视频| 天天综合色天天综合色h| 亚洲男人的天堂在线观看| 国产精品久久久久久久久搜平片 | 欧洲精品一区二区| 99久久99久久久精品齐齐| 成人18精品视频| www.欧美色图| 97精品国产97久久久久久久久久久久 | 欧美在线观看一区| 色天使久久综合网天天| av在线一区二区三区| jlzzjlzz欧美大全| 99精品视频一区| 一本在线高清不卡dvd| www.在线成人| 91在线视频播放地址| 色999日韩国产欧美一区二区| 极品少妇一区二区三区精品视频| 久久精品国产**网站演员| 亚洲黄色免费网站| 亚洲综合偷拍欧美一区色| 亚洲成人综合视频| 亚洲天堂久久久久久久| 亚洲摸摸操操av| 五月天欧美精品| 久国产精品韩国三级视频| 国产在线播放一区三区四| 成人app软件下载大全免费| 一本色道久久综合狠狠躁的推荐| 一本久道中文字幕精品亚洲嫩| 欧美日韩成人综合| 久久婷婷色综合| 1区2区3区国产精品| 亚洲影院在线观看| 奇米777欧美一区二区| 亚洲电影一区二区三区| 青青草成人在线观看| 国产成人综合网| 欧美性大战久久| 久久久久久久久伊人| 亚洲已满18点击进入久久| 精品在线一区二区三区| 91在线看国产| 91精品国产综合久久精品图片| 91国模大尺度私拍在线视频| 欧美一区二区在线免费播放| 欧美激情在线一区二区三区| 亚洲小说欧美激情另类| 国模冰冰炮一区二区| 色偷偷成人一区二区三区91| 日韩欧美综合一区| 亚洲欧美日韩国产另类专区| 看电影不卡的网站| 色综合色综合色综合| 26uuuu精品一区二区| 亚洲一区二区三区在线看| 国产在线精品不卡| 欧美三级日韩三级国产三级| 久久久亚洲国产美女国产盗摄| 一区二区三区四区在线播放| 国产在线不卡视频| 欧美精品日韩一本| 日韩亚洲欧美一区二区三区| 亚洲免费观看在线观看| 国产一区二区三区久久久 | 成人高清在线视频| 亚洲美女一区二区三区| 麻豆精品视频在线| 欧美亚洲免费在线一区| 中文字幕一区二区三区精华液| 激情五月激情综合网| 欧美老女人第四色| 成人免费在线播放视频| 国产精品资源在线看| 欧美不卡激情三级在线观看| 午夜视频一区二区三区| 色综合网色综合| 欧美日韩专区在线| 亚洲女爱视频在线| 成人午夜电影小说| 国产日韩欧美一区二区三区乱码 | 午夜久久久久久久久久一区二区| 99re8在线精品视频免费播放| 国产无人区一区二区三区| 国内不卡的二区三区中文字幕| 欧美大片在线观看一区二区| 午夜视黄欧洲亚洲| 91精品国产手机| 日韩电影一二三区| 99视频热这里只有精品免费| 国产精品热久久久久夜色精品三区| 久久99精品国产麻豆婷婷洗澡| 精品三级在线看| 精品无人码麻豆乱码1区2区|