View Javadoc

1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  package ch.qos.logback.core.db;
15  import java.sql.Connection;
16  import java.sql.SQLException;
17  
18  import ch.qos.logback.core.db.dialect.SQLDialectCode;
19  import ch.qos.logback.core.spi.LifeCycle;
20  
21  
22  /**
23   *  The <id>ConnectionSource</id> interface provides a pluggable means of
24   *  transparently obtaining JDBC {@link java.sql.Connection}s for logback classes
25   *  that require the use of a {@link java.sql.Connection}.
26   *  
27   * For more information about this component, please refer to the online manual at
28   * http://logback.qos.ch/manual/appenders.html#DBAppender
29   *
30   *  @author <a href="mailto:rdecampo@twcny.rr.com">Ray DeCampo</a>
31   */
32  public interface ConnectionSource extends LifeCycle {
33  
34    /**
35     *  Obtain a {@link java.sql.Connection} for use.  The client is
36     *  responsible for closing the {@link java.sql.Connection} when it is no
37     *  longer required.
38     *
39     *  @throws SQLException  if a {@link java.sql.Connection} could not be
40     *                        obtained
41     */
42    Connection getConnection() throws SQLException;
43  
44    /**
45     * Get the SQL dialect that should be used for this connection. Note that the
46     * dialect is not needed if the JDBC driver supports the getGeneratedKeys 
47     * method.
48     */
49    SQLDialectCode getSQLDialectCode();
50    
51    /**
52     * If the connection supports the JDBC 3.0 getGeneratedKeys method, then
53     * we do not need any specific dialect support.
54     */
55    boolean supportsGetGeneratedKeys();
56    
57    /**
58     * If the connection does not support batch updates, we will avoid using them.
59     */  
60    public boolean supportsBatchUpdates();
61  }