2012-03-02 13 views
1

私はJTDSドライバを使ってJavaアプリケーションからMSSQLへLiquibaseを実行しています。更新プログラムを実行すると表示されますが、実際にはデータベースにコミットされるものはありません。何か案は?以下のコードはサーブレットで動作します。Liquibaseは私の変更をコミットしません

Connection con = null; 
    try { 
     Properties props = new Properties(); 
     props.load(getClass().getResourceAsStream("/datasource.properties")); 
     String driver = props.getProperty("database.driver"); 
     String url = props.getProperty("database.url"); 
     String username = props.getProperty("database.username"); 
     String password = props.getProperty("database.password"); 
     Class.forName(driver); 
     con = DriverManager.getConnection(url, username, password); 

     Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(con)); 
     Liquibase liquibase = new Liquibase("db.xml", new ClassLoaderResourceAccessor(), database); 
     response.getWriter().print("<PRE>"); 
     liquibase.update("", response.getWriter()); 

     con.commit(); 
    } catch (Exception e) { 
     log.error(e.getMessage(), e); 
     throw new ServletException(e.getMessage(), e); 
    } finally { 
     if (con != null) { 
      try { 
       con.close(); 
      } catch (SQLException e) { 
       log.warn(e.getMessage(), e); 
      } 
     } 
    } 
    response.flushBuffer(); 

答えて

2

writerを取るupdate()メソッドは変更を実行せず、実行されるものを出力します。

代わりにliquibase.update( "")またはliquibase.update(null)を呼び出すと、変更が実行されます。

関連する問題