NutzCN Logo
问答 dao 能否直接执行sql文件,不要 注释一行、sql语句一行
发布于 2880天前 作者 大鲨鱼 3556 次浏览 复制 上一个帖子 下一个帖子
标签: dao

如题:

            FileSqlManager fm = new FileSqlManager("sql/init_quartz.sql");
            List<Sql> sqlList = fm.createCombo(fm.keys());
            dao.execute(sqlList.toArray(new Sql[sqlList.size()]));
6 回复

要是严格遵守一行一条SQL,那么直接按行分隔就是了.

无规则的sql,反正是放在命令行能直接执行的sql,,这个应该能支持吧?

#
# In your Quartz properties file, you'll need to set 
# org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
#
#
# By: Ron Cordell - roncordell
#  I didn't see this anywhere, so I thought I'd post it here. This is the script from Quartz to create the tables in a MySQL database, modified to use INNODB instead of MYISAM.

DROP TABLE IF EXISTS SYS_QRTZ_FIRED_TRIGGERS;
DROP TABLE IF EXISTS SYS_QRTZ_PAUSED_TRIGGER_GRPS;
DROP TABLE IF EXISTS SYS_QRTZ_SCHEDULER_STATE;
DROP TABLE IF EXISTS SYS_QRTZ_LOCKS;
DROP TABLE IF EXISTS SYS_QRTZ_SIMPLE_TRIGGERS;
DROP TABLE IF EXISTS SYS_QRTZ_SIMPROP_TRIGGERS;
DROP TABLE IF EXISTS SYS_QRTZ_CRON_TRIGGERS;
DROP TABLE IF EXISTS SYS_QRTZ_BLOB_TRIGGERS;
DROP TABLE IF EXISTS SYS_QRTZ_TRIGGERS;
DROP TABLE IF EXISTS SYS_QRTZ_JOB_DETAILS;
DROP TABLE IF EXISTS SYS_QRTZ_CALENDARS;

CREATE TABLE SYS_QRTZ_JOB_DETAILS(
SCHED_NAME VARCHAR(120) NOT NULL,
JOB_NAME VARCHAR(200) NOT NULL,
JOB_GROUP VARCHAR(200) NOT NULL,
DESCRIPTION VARCHAR(250) NULL,
JOB_CLASS_NAME VARCHAR(250) NOT NULL,
IS_DURABLE VARCHAR(1) NOT NULL,
IS_NONCONCURRENT VARCHAR(1) NOT NULL,
IS_UPDATE_DATA VARCHAR(1) NOT NULL,
REQUESTS_RECOVERY VARCHAR(1) NOT NULL,
JOB_DATA BLOB NULL,
PRIMARY KEY (SCHED_NAME,JOB_NAME,JOB_GROUP))
ENGINE=InnoDB;

CREATE TABLE SYS_QRTZ_TRIGGERS (
SCHED_NAME VARCHAR(120) NOT NULL,
TRIGGER_NAME VARCHAR(200) NOT NULL,
TRIGGER_GROUP VARCHAR(200) NOT NULL,
JOB_NAME VARCHAR(200) NOT NULL,
JOB_GROUP VARCHAR(200) NOT NULL,
DESCRIPTION VARCHAR(250) NULL,
NEXT_FIRE_TIME BIGINT(13) NULL,
PREV_FIRE_TIME BIGINT(13) NULL,
PRIORITY INTEGER NULL,
TRIGGER_STATE VARCHAR(16) NOT NULL,
TRIGGER_TYPE VARCHAR(8) NOT NULL,
START_TIME BIGINT(13) NOT NULL,
END_TIME BIGINT(13) NULL,
CALENDAR_NAME VARCHAR(200) NULL,
MISFIRE_INSTR SMALLINT(2) NULL,
JOB_DATA BLOB NULL,
PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
FOREIGN KEY (SCHED_NAME,JOB_NAME,JOB_GROUP)
REFERENCES SYS_QRTZ_JOB_DETAILS(SCHED_NAME,JOB_NAME,JOB_GROUP))
ENGINE=InnoDB;

[INFO ] 11:10:37.893 org.nutz.dao.impl.FileSqlManager.add(FileSqlManager.java:109) - skip not key sql line JOB_GROUP VARCHAR(200) NOT NULL,
[INFO ] 11:10:37.894 org.nutz.dao.impl.FileSqlManager.add(FileSqlManager.java:109) - skip not key sql line DESCRIPTION VARCHAR(250) NULL,
[INFO ] 11:10:37.894 org.nutz.dao.impl.FileSqlManager.add(FileSqlManager.java:109) - skip not key sql line JOB_CLASS_NAME VARCHAR(250) NOT NULL,
[INFO ] 11:10:37.895 org.nutz.dao.impl.FileSqlManager.add(FileSqlManager.java:109) - skip not key sql line IS_DURABLE VARCHAR(1) NOT NULL,
[INFO ] 11:10:37.895 org.nutz.dao.impl.FileSqlManager.add(FileSqlManager.java:109) - skip not key sql line IS_NONCONCURRENT VARCHAR(1) NOT NULL,
[INFO ] 11:10:37.896 org.nutz.dao.impl.FileSqlManager.add(FileSqlManager.java:109) - skip not key sql line IS_UPDATE_DATA VARCHAR(1) NOT NULL,
[INFO ] 11:10:37.896 org.nutz.dao.impl.FileSqlManager.add(FileSqlManager.java:109) - skip not key sql line REQUESTS_RECOVERY VARCHAR(1) NOT NULL,

其实嘛,是数据库驱动不支持一次执行n条sql

好像以前讲过 ,,mark吧

添加回复
请先登陆
回到顶部