title: Logback DBAppender, configuring programmatically throwing exception
body: <p>I am trying to configure Logback' DBAppender programmatically, but don't know what's going wrong. It works fine with logback.xml configuration given below</p>
  
  <pre><code>&lt;appender name="DB" class="ch.qos.logback.classic.db.DBAppender"&gt;
      &lt;connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource"&gt;
          &lt;driverClass&gt;com.mysql.jdbc.Driver&lt;/driverClass&gt;
          &lt;jdbcUrl&gt;jdbc:mysql://localhost:3306/mydatabase&lt;/jdbcUrl&gt;
          &lt;user&gt;myuser&lt;/user&gt;
          &lt;password&gt;mypwd&lt;/password&gt;
      &lt;/connectionSource&gt;
    &lt;/appender&gt;
  </code></pre>
  
  <p>now when I'm trying to get and configure Logger in code like this</p>
  
  <pre><code>Logger logger = (Logger) LoggerFactory.getLogger("dbAppender");
  
          LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
  
          DriverManagerConnectionSource dmcs = new DriverManagerConnectionSource();
          dmcs.setDriverClass("com.mysql.jdbc.Driver");
          dmcs.setUrl("jdbc:mysql://localhost:3306/mydatabase");
          dmcs.setUser("myuser");
          dmcs.setPassword(mypwd);
          dmcs.setContext(lc);
  
          DBAppender dbapp =  (DBAppender) logger.getAppender("DB");
  //it returns an appender with properties in logback.xml file
           if(dbapp != null) {
              dbapp.stop();
              dbapp.setConnectionSource(dmcs);
              dbapp.start();
           }
  </code></pre>
  
  <p>it throws exception</p>
  
  <pre><code>java.lang.IllegalStateException: DBAppender cannot function if the JDBC driver does not support getGeneratedKeys method *and* without a specific SQL dialect
      at ch.qos.logback.core.db.DBAppenderBase.start(DBAppenderBase.java:62)
      at ch.qos.logback.classic.db.DBAppender.start(DBAppender.java:96)
  </code></pre>
  
  <p>There is no way to set dialect or setGeneratedKey, what do I need to make it work.</p>