ibatis mysql sqlmapconfig,生手使用ibatis出错:Element type "SqlMapConfig" must be declared

当前位置:我的异常网» J2EE » 生手使用ibatis出错:Element type "SqlMapCon

生手使用ibatis出错:Element type "SqlMapConfig" must be declared

www.myexceptions.net  网友分享于:2013-04-06  浏览:168次

新手使用ibatis出错:Element type "SqlMapConfig" must be declared.

各路英雄好汉,江湖救急:刚接触iBatis(工程导入了mybatis-2.3.5.jar,mySQL 驱动包)

SqlMapConfig.xml 文件内容如下:

SqlMapConfig

PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"

"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">

student.xml 文件内容如下 :

sqlMap

PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"

"http://ibatis.apache.org/dtd/sql-map-2.dtd">

select * from student_table

SqlMap.properties 文件内容如下 :

driver = "com.mysql.jdbc.Driver"

url = "jdbc:mysql://localhost:3306/myIbatisDB"

username="root"

password="fhlu18"

写了一个方法 studentDaoImpl.jva

import java.io.IOException;

import java.io.Reader;

import java.sql.SQLException;

import java.util.List;

import myIbatis.Student;

import com.ibatis.sqlmap.client.SqlMapClient;

public class StudentDaoImpl implements StudentDao {

private static SqlMapClient sqlMapClient = null;

static {

try {

Reader reader = com.ibatis.common.resources.Resources.getResourceAsReader("myIbatis/SqlMapConfig.xml");

sqlMapClient = com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(reader);

reader.close();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

public List queryAllStudent() {

List studentList = null;

try {

studentList = sqlMapClient.queryForList("selectAllStudent");

} catch (SQLException e) {

e.printStackTrace();

}

return studentList ;

文章评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值