[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
package jp.co.sample.main;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.List;
import jp.co.sample.bean.SampleTempBean;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
public class SampleMain {
private static final String SQL_OUTPUT_PATH = "./sql/";
private static final String TABLE_TEIGI_PATH = "./xls/";
public static void main(String[] args) {
try {
/* テキストファイル読み込み */
List<SampleTempBean> sampleTempBeanList = ControllerExcel.readExcel(TABLE_TEIGI_PATH);
Velocity.init();// Velocity初期化
BufferedWriter writer = new BufferedWriter(new FileWriter(
SQL_OUTPUT_PATH + "動的SQL作成.txt"));
for (SampleTempBean sampleTempBean : sampleTempBeanList) {
VelocityContext ctx = new VelocityContext();
// テーブル名をセット
ctx.put("sampleTempBean", sampleTempBean);
Template template = Velocity
.getTemplate("./template/temp.vm");
template.merge(ctx, writer);
}
for (SampleTempBean sampleTempBean : sampleTempBeanList) {
VelocityContext ctx = new VelocityContext();
// テーブル名をセット
ctx.put("sampleTempBean", sampleTempBean);
Template template = Velocity
.getTemplate("./template/temp2.vm");
template.merge(ctx, writer);
}
writer.flush();
writer.close();
} catch (Exception e) {
e.printStackTrace();
System.out.println("致命的なエラーだ。大変だ・・・");
}
System.out.println("正常終了");
}
}