title: Liquibase Java, changesets don't apply
body: <p>I'm currently building a project for my internship, and I'm stuck since two days trying to use Liquibase in java. Everything seems right : the changelog file is found, correct URI, username and password; but when I run it, my changesets are not processed.</p>
  
  <p>I use this class to manage liquibase actions from my program, such as <em>rollback</em>, <em>update</em>, <em>updateSQL</em> and <em>futureRollbackSQL</em>, given a changelog and eventually a destination file. If the source or destination is from a remote server, I use some SSH interactions (scp to, scp from) with <strong>JSch</strong> and temporary files (but it's not the topic).</p>
  
  <p>This is the java code I have for now, given <strong>db</strong>, <strong>user</strong>, <strong>passwd</strong>, <strong>realAction</strong> are set previously, <strong>changelogpath</strong> and <strong>dest</strong> are some data storage class.</p>
  
  <pre class="lang-java prettyprint-override"><code>Connection c = null;
  Database database = null;
  PrintWriter pw = null;
  File file = null;
  liquibase.Liquibase liquibase = null;
  contexts = db+"."+user;
  try {
      pw = new PrintWriter(new FileWriter(file));
      // Get connection
      c = SQLManager.getInstance().getConnection(db, user, passwd);
      // Get liquibase connection
      database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(c));
      liquibase = new liquibase.Liquibase(new DatabaseChangeLog(fsource), new FileSystemResourceAccessor(),
              database);
      // Run liquibase action
      switch (realAction) {
          case Constants.LIQUIBASE_ACTION_FUTUREROLLBACKSQL:
              liquibase.futureRollbackSQL(pw);
              break;
          case Constants.LIQUIBASE_ACTION_UPDATESQL:
              liquibase.update(contexts, pw);
              break;
          case Constants.LIQUIBASE_ACTION_UPDATE:
              liquibase.update(contexts);
              if (!c.getAutoCommit())
                  c.commit();
              break;
          default:
              throw new OdewipElementRuntimeException(this, "Action not implemented");
      }
      pw.close();
      database.close();
      c.close();
  } catch (IOException | SQLException | LiquibaseException e) {
      throw new Exception(e.getMessage());
  } finally {
      if (c != null) {
          try {
              c.close();
          } catch (SQLException e) {
              // nothing to do
              throw new RuntimeException(e.getClass() + ": " + e.getMessage());
          }
      }
  }
  </code></pre>
  
  <p>And here is my changelog:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ora="http://www.liquibase.org/xml/ns/dbchangelog-ext"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd    http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"&gt;    
  
      &lt;changeSet id="mychangeset" author="testy"&gt;
          &lt;preConditions onSqlOutput="TEST" onFail="MARK_RAN"&gt;
              &lt;not&gt;
                  &lt;tableExists tableName="abcd"/&gt;
              &lt;/not&gt;
          &lt;/preConditions&gt;
          &lt;createTable tableName="abcd"&gt;
              &lt;column name="id" type="number"&gt;
                  &lt;constraints primaryKey="true"/&gt;
              &lt;/column&gt;
          &lt;/createTable&gt;
      &lt;/changeSet&gt;
  
  &lt;/databaseChangeLog&gt;
  </code></pre>
  
  <p>Liquibase seems to do <em>something</em>, except parsing my changeset. When I launch my actions, sql generated files only contains the creation of the two tables of liquibase (databasechangelog and databasechangeloglock) and that's all. The <strong>update</strong> action won't modify anything at all (not even creating the two previously mentioned tables). I'm (100%) sure that the table <em>abcd</em> does not exist in the database before execution.</p>
  
  <p>So I think I need some help at this point, to figure out what isn't working. I tried to look at some examples from the liquibase forum, but nothing helped.
  I'm currently using Maven's liquibase 3.4.0:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.liquibase&lt;/groupId&gt;
      &lt;artifactId&gt;liquibase-core&lt;/artifactId&gt;
      &lt;version&gt;3.4.0&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Is there another dependency to include I missed?
  One small other question is how do I include a special oracle database driver(ojdbc6.jar)? </p>
  
  <p>Thank you for your answers.</p>
  
  <p><strong>EDIT 06/08/2015:</strong> 
  I got the logs in debug mode (deliberately changed the schema name):</p>
  
  <pre><code>DEBUG 06/08/15 09:28: liquibase: Executing QUERY database command: select count(*) from MYSCHEMA.DATABASECHANGELOGLOCK
  DEBUG 06/08/15 09:28: liquibase: Create Database Lock Table
  DEBUG 06/08/15 09:28: liquibase: Executing EXECUTE database command: CREATE TABLE MYSCHEMA.DATABASECHANGELOGLOCK (ID NUMBER(10) NOT NULL, LOCKED NUMBER(1) NOT NULL, LOCKGRANTED TIMESTAMP, LOCKEDBY VARCHAR2(255), CONSTRAINT PK_DATABASECHANGELOGLOCK PRIMARY KEY (ID))
  DEBUG 06/08/15 09:28: liquibase: Created database lock table with name: MYSCHEMA.DATABASECHANGELOGLOCK
  DEBUG 06/08/15 09:28: liquibase: Executing QUERY database command: select count(*) from MYSCHEMA.DATABASECHANGELOGLOCK
  DEBUG 06/08/15 09:28: liquibase: Initialize Database Lock Table
  DEBUG 06/08/15 09:28: liquibase: Executing EXECUTE database command: DELETE FROM MYSCHEMA.DATABASECHANGELOGLOCK
  DEBUG 06/08/15 09:28: liquibase: Executing EXECUTE database command: INSERT INTO MYSCHEMA.DATABASECHANGELOGLOCK (ID, LOCKED) VALUES (1, 0)
  DEBUG 06/08/15 09:28: liquibase: Executing QUERY database command: SELECT LOCKED FROM MYSCHEMA.DATABASECHANGELOGLOCK WHERE ID=1 FOR UPDATE
  DEBUG 06/08/15 09:28: liquibase: Lock Database
  DEBUG 06/08/15 09:28: liquibase: Executing UPDATE database command: UPDATE MYSCHEMA.DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = 'CRO09177 (xx.xx.xx.xxx)', LOCKGRANTED = to_date('2015-08-06 09:28:28', 'YYYY-MM-DD HH24:MI:SS') WHERE ID = 1 AND LOCKED = 0
  INFO 06/08/15 09:28: liquibase: Successfully acquired change log lock
  DEBUG 06/08/15 09:28: liquibase: Create Database Change Log Table
  INFO 06/08/15 09:28: liquibase: Creating database history table with name: MYSCHEMA.DATABASECHANGELOG
  DEBUG 06/08/15 09:28: liquibase: Executing EXECUTE database command: CREATE TABLE MYSCHEMA.DATABASECHANGELOG (ID VARCHAR2(255) NOT NULL, AUTHOR VARCHAR2(255) NOT NULL, FILENAME VARCHAR2(255) NOT NULL, DATEEXECUTED TIMESTAMP NOT NULL, ORDEREXECUTED NUMBER(10) NOT NULL, EXECTYPE VARCHAR2(10) NOT NULL, MD5SUM VARCHAR2(35), DESCRIPTION VARCHAR2(255), COMMENTS VARCHAR2(255), TAG VARCHAR2(255), LIQUIBASE VARCHAR2(20), CONTEXTS VARCHAR2(255), LABELS VARCHAR2(255))
  DEBUG 06/08/15 09:28: liquibase: Executing QUERY database command: select count(*) from MYSCHEMA.DATABASECHANGELOG
  INFO 06/08/15 09:28: liquibase: Reading from MYSCHEMA.DATABASECHANGELOG
  DEBUG 06/08/15 09:28: liquibase: Executing QUERY database command: SELECT FILENAME,AUTHOR,ID,MD5SUM,DATEEXECUTED,ORDEREXECUTED,EXECTYPE,DESCRIPTION,COMMENTS,TAG,LIQUIBASE,LABELS,CONTEXTS FROM MYSCHEMA.DATABASECHANGELOG ORDER BY DATEEXECUTED ASC, ORDEREXECUTED ASC
  DEBUG 06/08/15 09:28: liquibase: Executing QUERY database command: select count(*) from MYSCHEMA.DATABASECHANGELOGLOCK
  DEBUG 06/08/15 09:28: liquibase: Release Database Lock
  DEBUG 06/08/15 09:28: liquibase: Executing UPDATE database command: UPDATE MYSCHEMA.DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1
  INFO 06/08/15 09:28: liquibase: Successfully released change log lock
  </code></pre>