ibatis执行SQL脚本没有得到结果?

Propertiesprops=Resources.getResourceAsProperties("maindbconn.properties");Stringurl=... Properties props = Resources
.getResourceAsProperties("maindbconn.properties");
String url = props.getProperty("connString");
String driver = props.getProperty("driverName");
String username = props.getProperty("userName");
String password = props.getProperty("password");
System.out.println(url);

Class.forName(driver).newInstance();
Connection conn = (Connection) DriverManager.getConnection(url,
username, password);
ScriptRunner runner = new ScriptRunner(conn, false, false);
runner.setErrorLogWriter(null);
runner.setLogWriter(null);
runner.runScript(Resources
.getResourceAsReader("1.sql"));
runner.runScript(Resources
.getResourceAsReader("2.sql"));
展开
 我来答
百度网友49c3702
2015-07-04 · TA获得超过100个赞
知道答主
回答量:55
采纳率:0%
帮助的人:15.3万
展开全部
你确保你路径对的?Rosource 默认在java编译后的class目录下
比如
源代码
-src
|-*.properties
|-*.sql
编译后:
-classes
|-*.properties
|-*.sql

runner.setErrorLogWriter(null);
runner.setLogWriter(null);
这两句不要
因为原构造函数如下:
public ScriptRunner(Connection connection, boolean autoCommit, boolean stopOnError) {
this.logWriter = new PrintWriter(System.out);
this.errorLogWriter = new PrintWriter(System.err);
this.delimiter = ";";
this.fullLineDelimiter = false;
this.connection = connection;
this.autoCommit = autoCommit;
this.stopOnError = stopOnError;
}
希望我的回答能帮到你!!!!
追问
path是对的
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式