2012-03-02 5 views
1

JTDS 드라이버를 사용하여 Java 응용 프로그램에서 Liquibase를 MSSQL으로 실행하고 있습니다. 업데이트를 실행하면 표시되는 것을 볼 수 있지만 실제로는 데이터베이스에 커밋되지 않습니다. 어떤 아이디어? 아래 코드는 서블릿에서 실행됩니다.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)을 호출하면 변경 사항이 실행됩니다.

관련 문제