|
|
|
@ -1,39 +0,0 @@
|
|
|
|
|
package UnitTest.ImportExcel;
|
|
|
|
|
|
|
|
|
|
import com.jfinal.kit.PropKit;
|
|
|
|
|
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
|
|
|
|
import com.jfinal.plugin.activerecord.CaseInsensitiveContainerFactory;
|
|
|
|
|
import com.jfinal.plugin.activerecord.dialect.PostgreSqlDialect;
|
|
|
|
|
import com.jfinal.plugin.hikaricp.HikariCpPlugin;
|
|
|
|
|
|
|
|
|
|
public class createTable {
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
|
//告之配置文件位置
|
|
|
|
|
PropKit.use("application.properties");
|
|
|
|
|
HikariCpPlugin hp = new HikariCpPlugin(PropKit.get("jdbcUrl"), PropKit.get("user"),
|
|
|
|
|
PropKit.get("password").trim(), PropKit.get("driverClassName"));
|
|
|
|
|
hp.start();
|
|
|
|
|
// 配置ActiveRecord插件
|
|
|
|
|
ActiveRecordPlugin arp = new ActiveRecordPlugin(hp);
|
|
|
|
|
//配置默认小写
|
|
|
|
|
arp.setContainerFactory(new CaseInsensitiveContainerFactory(true));
|
|
|
|
|
arp.setDialect(new PostgreSqlDialect());
|
|
|
|
|
arp.start();
|
|
|
|
|
|
|
|
|
|
// //测试两个导入模板
|
|
|
|
|
// String workingPath = "D:\\dsWork\\QingLong\\src\\main\\java\\UnitTest\\ImportExcel\\";
|
|
|
|
|
// String filePath = workingPath + "测试1.xlsx";
|
|
|
|
|
// String tableName = "ds_gtzz_t_bmwj";//表名,研发人员在界面上录入,程序需要检查此表名是不是存在,如果存在返回错误信息,不存在,则可以生成创建表的SQL语句
|
|
|
|
|
// ExcelUtil.dropTable(tableName);
|
|
|
|
|
// ExcelUtil.createTable(tableName, filePath);
|
|
|
|
|
// ExcelUtil.importData(tableName, filePath);
|
|
|
|
|
//
|
|
|
|
|
// filePath = workingPath + "测试2.xlsx";
|
|
|
|
|
// tableName = "ds_gtzz_t_zc";//表名,研发人员在界面上录入,程序需要检查此表名是不是存在,如果存在返回错误信息,不存在,则可以生成创建表的SQL语句
|
|
|
|
|
// ExcelUtil.dropTable(tableName);
|
|
|
|
|
// ExcelUtil.createTable(tableName, filePath);
|
|
|
|
|
// ExcelUtil.importData(tableName, filePath);
|
|
|
|
|
//
|
|
|
|
|
// System.out.println("恭喜,所有操作成功完成!");
|
|
|
|
|
}
|
|
|
|
|
}
|