Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Logback: the reliable, generic, fast and flexible logging framework. Copyright (C) 1999-2011, All rights reserved. This program and the accompanying materials are dual-licensed under either the terms of the Eclipse Public License v1.0 as published by the Eclipse Foundation or (per the licensee's choosing) under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.
package ch.qos.logback.core.db;
The DataSourceConnectionSource is an implementation of ConnectionSource that obtains the Connection in the recommended JDBC manner based on a DataSource.

For more information about this component, please refer to the online manual at

Ray DeCampo
Ceki Gülcü
  private DataSource dataSource;
  public void start() {
    if ( == null) {
      addWarn("WARNING: No data source specified");
    } else {
      Connection connection = null;
      try {
        connection = getConnection();
      } catch (SQLException se) {
        addWarn("Could not get a connection to discover the dialect to use.",
      if (connection != null) {
      if (!supportsGetGeneratedKeys()
          && getSQLDialectCode() == .) {
        addWarn("Connection does not support GetGeneratedKey method and could not discover the dialect.");

  public Connection getConnection() throws SQLException {
    if ( == null) {
      addError("WARNING: No data source specified");
      return null;
    if (getUser() == null) {
      return .getConnection();
    } else {
      return .getConnection(getUser(), getPassword());
  public DataSource getDataSource() {
    return ;
  public void setDataSource(DataSource dataSource) {
    this. = dataSource;
New to GrepCode? Check out our FAQ X