这里 文件中的sql
DROP TABLE IF EXISTS t_accounts2016;
CREATE TABLE t_accounts2016 (
accounts_ID1 varchar(18) default NULL ,
accounts_ID2 varchar(18) default NULL ,
accounts_name varchar(200) default NULL ,
accounts_level char(2) default NULL ,
parent_code varchar(16) default NULL,
create_time datetime default NULL,
upd_date datetime default NULL,
valid_flag char(1) default NULL ,
extend_flag char(2) default NULL ,
accounts_year char(4) default NULL,
subject_month char(2) default NULL ,
hl_flag char(1) default NULL ,
inc_exp_flag char(1) default NULL ,
id int(11) NOT NULL auto_increment ,
upd_user_id varchar(50) default NULL ,
index(accounts_ID2),
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
这里是 读取并执行
((NutDao)dao).setSqlManager(new FileSqlManager("/sqls"));
System.out.println(dao.sqls().count());
Sql sql = dao.sqls().create("create.sql");
sql.vars().set("year", 2016);
dao.execute(sql);
出错代码
Caused by: org.nutz.dao.DaoException: !Nutz SQL Error: 'DROP TABLE IF EXISTS t_accounts2016;
CREATE TABLE t_accounts2016 (
accounts_ID1 varchar(18) default NULL ,
accounts_ID2 varchar(18) default NULL ,
accounts_name varchar(200) default NULL ,
accounts_level char(2) default NULL ,
parent_code varchar(16) default NULL,
create_time datetime default NULL,
upd_date datetime default NULL,
valid_flag char(1) default NULL ,
extend_flag char(2) default NULL ,
accounts_year char(4) default NULL,
subject_month char(2) default NULL ,
hl_flag char(1) default NULL ,
inc_exp_flag char(1) default NULL ,
id int(11) NOT NULL auto_increment ,
upd_user_id varchar(50) default NULL ,
index(accounts_ID2),
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;'
PreparedStatement:
'DROP TABLE IF EXISTS t_accounts2016;
CREATE TABLE t_accounts2016 (
accounts_ID1 varchar(18) default NULL ,
accounts_ID2 varchar(18) default NULL ,
accounts_name varchar(200) default NULL ,
accounts_level char(2) default NULL ,
parent_code varchar(16) default NULL,
create_time datetime default NULL,
upd_date datetime default NULL,
valid_flag char(1) default NULL ,
extend_flag char(2) default NULL ,
accounts_year char(4) default NULL,
subject_month char(2) default NULL ,
hl_flag char(1) default NULL ,
inc_exp_flag char(1) default NULL ,
id int(11) NOT NULL auto_increment ,
upd_user_id varchar(50) default NULL ,
index(accounts_ID2),
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;'
CaseMessage=You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TABLE t_accounts2016 (
accounts_ID1 varchar(18) default NULL ,
accounts_I' at line 2
新人求解,原生sql 在mysql中可以直接插入,但是代码却不行