View Javadoc

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