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, QOS.ch. 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 DriverManagerConnectionSource is an implementation of ConnectionSource that obtains the Connection in the traditional JDBC manner based on the connection URL.

For more information about this component, please refer to the online manual at http://logback.qos.ch/manual/appenders.html#DBAppender

Author(s):
Ray DeCampo
  private String driverClass = null;
  private String url = null;
  public void start() {
    try {
      if ( != null) {
        Class.forName();
      } else {
        addError("WARNING: No JDBC driver specified for logback DriverManagerConnectionSource.");
      }
    } catch (final ClassNotFoundException cnfe) {
      addError("Could not load JDBC driver class: " + cnfe);
    }
  }

  
  public Connection getConnection() throws SQLException {
    if (getUser() == null) {
      return DriverManager.getConnection();
    } else {
      return DriverManager.getConnection(getUser(), getPassword());
    }
  }

  
Returns the url.

Returns:
String
  public String getUrl() {
    return ;
  }

  
Sets the url.

Parameters:
url The url to set
  public void setUrl(String url) {
    this. = url;
  }

  
Returns the name of the driver class.

Returns:
String
  public String getDriverClass() {
    return ;
  }

  
Sets the driver class.

Parameters:
driverClass The driver class to set
  public void setDriverClass(String driverClass) {
    this. = driverClass;
  }
New to GrepCode? Check out our FAQ X