0

我需要使用 JDBC 将 DDL(最好保存在文件中)安装到数据库中。我在“Statement”API 中看到了 addBatch() 和 executeBatch() 方法,但它们似乎需要一次添加一个单独的语句。我正在尝试找到一种方法来添加大量语句(DDL),我可以将它们存储在文件中并作为参数传递到 Java 应用程序中,然后使用 JDBC 进行安装。

4

1 回答 1

0

I'm going to give an answer that I think will help you maintainability wise, but it may not be what you're looking for. Here are two libraries that help with database migrations:

  1. http://www.liquibase.org/
  2. http://flywaydb.org/

Not only will these help you execute DDL in a file, they bring lots of other features you don't want to have to reinvent. EG, they'll make sure they only get run once if they succeed.

If these aren't the right tool for the job, I think the comment @Alpesh Gediya made is what you're looking for.

于 2013-05-29T17:47:05.880 回答