免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2803 | 回复: 2
打印 上一主题 下一主题

请教ibatis运行异常 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-12-05 19:22 |只看该作者 |倒序浏览
50可用积分
日志:
2007-12-03 21:06:47,828 INFO [lsjGui.JinRu] - com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in lsjDomain/Js.xml.
--- The error occurred while applying a result map.
--- Check the Js.RMJs.
--- The error happened while setting a property on the result object.
--- Cause: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Can´t start a cloned connection while in manual transaction mode.

代码:
lsjGui/JinRu.java

  1. ...
  2. private static final Logger log = Logger.getLogger(JinRu.class);

  3. private static SqlMapClient sqlMapper;
  4. static {
  5. try {
  6. Reader reader = Resources
  7. .getResourceAsReader("lsjDomain/SqlMapConfig.xml");
  8. sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
  9. reader.close();
  10. } catch (IOException e) {
  11. throw new RuntimeException(
  12. "Something bad happened while building the SqlMapClient instance."
  13. + e, e);
  14. }
  15. }

  16. public void zb() {
  17. try {
  18. sqlMapper.startTransaction();
  19. List js = sqlMapper.queryForList("queryAll");
  20. sqlMapper.commitTransaction();
  21. } catch (Exception e) {
  22. log.info(e.toString());
  23. System.exit(0);
  24. } finally {
  25. try {
  26. sqlMapper.endTransaction();
  27. }
  28. catch (Exception e) {
  29. log.info(e.toString());
  30. System.exit(0);
  31. }
  32. }
复制代码


====================
lsjDomain/SqlMapConfig.xml

  1. <?xml version="1.0" encoding="UTF-8" ?>

  2. <!DOCTYPE sqlMapConfig
  3. PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
  4. "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">

  5. <sqlMapConfig>
  6. <transactionManager type="JDBC" commitRequired="false">
  7. <dataSource type="SIMPLE">
  8. <property name="JDBC.Driver"
  9. value="com.microsoft.jdbc.sqlserver.SQLServerDriver" />
  10. <property name="JDBC.ConnectionURL"
  11. value="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=EMIS" />
  12. <property name="JDBC.Username" value="sa" />
  13. <property name="JDBC.Password" value="" />
  14. </dataSource>
  15. </transactionManager>

  16. <sqlMap resource="lsjDomain/Js.xml" />

  17. </sqlMapConfig>
复制代码


========
lsjDomain/Js.java

  1. package lsjDomain;

  2. import java.io.IOException;
  3. import java.io.Reader;
  4. import java.sql.SQLException;
  5. import java.util.List;

  6. import com.ibatis.common.resources.Resources;
  7. import com.ibatis.sqlmap.client.SqlMapClient;
  8. import com.ibatis.sqlmap.client.SqlMapClientBuilder;

  9. public class Js {
  10. public Integer c0;
  11. public String c1;
  12. public Integer getC0() {
  13. return c0;
  14. }
  15. public void setC0(int c0) {
  16. this.c0 = c0;
  17. }
  18. public String getC1() {
  19. return c1;
  20. }
  21. public void setC1(String c1) {
  22. this.c1 = c1;
  23. }
  24. public String toString() {
  25. return "c0 = "+c0+ " , c1 = "+c1;
  26. }
  27. }
复制代码


========
lsjDomain/Js.xml

  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE sqlMap
  3. PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
  4. "http://ibatis.apache.org/dtd/sql-map-2.dtd">
  5. <sqlMap namespace="Js">
  6. <typeAlias alias="js" type="lsjDomain.Js" />
  7. <resultMap class="js" id="RMJs">
  8. <result property="c0" column="c0" />
  9. <result property="c1" column="c1" />
  10. </resultMap>
  11. <select id="queryAll" resultMap="RMJs">
  12. select c0, c1 from emis_1
  13. </select>
  14. </sqlMap>
复制代码

最佳答案

查看完整内容

参考这里http://support.microsoft.com/kb/313181/zh-cn

论坛徽章:
0
2 [报告]
发表于 2007-12-05 19:22 |只看该作者
jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs;SelectMethod=Direct;User=User;Password=Password
==>
jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs;SelectMethod=Cursor;User=User;Password=Password

参考这里
http://support.microsoft.com/kb/313181/zh-cn

论坛徽章:
0
3 [报告]
发表于 2007-12-06 07:05 |只看该作者
谢谢
我来试试
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP