求助:第一个ibatis程序连不上oracle
代码直接贴上吧:
总配置:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMapConfig
PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<properties resource="SqlMap.properties" />
<transactionManager type="JDBC" commitRequired="false">
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="${driver}" />
<property name="JDBC.ConnectionURL" value="${url}" />
<property name="JDBC.Username" value="${username}" />
<property name="JDBC.Password" value="${password}" />
</dataSource>
</transactionManager>
<sqlMap resource="Student.xml" />
</sqlMapConfig>
SqlMap.properties
driver=oracle.jdbc.OracleDriver
url=jdbc:oracle:thin:@127.0.0.1:1521/ORACLE
username=scott
passwd=tiger
Student.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org/DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap>
<typeAlias alias="Student" type="com.dd.Student"></typeAlias>
<select id="selectAllStudent" resultClass="Student">
select *
from student
</select>
</sqlMap>
StudentDAO.java
package com.dd;
import java.util.List;
public interface StudentDAO {
public void addStudent(Student student);
public void addStudentBySequence(Student student);
public void deleteStudentById(int id);
public List<Student> queryAllStudent();
public List<Student> queryStudentByName(String name);
public Student queryStudentById(int id);
public void updateStudent(Student student);
}
StudentDAOImpl.java:
package com.dd;
import java.io.IOException;
import java.io.Reader;
import java.sql.SQLException;
import java.util.List;
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("com/dd/SqlMapConfig.xml");
sqlMapClient=com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(reader);
reader.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static SqlMapClient getSqlMapClient() {
return sqlMapClient;
}
public void addStudent(Student student) {
// TODO Auto-generated method stub
}
public void addStudentBySequence(Student student) {
// TODO Auto-generated method stub
}
public void deleteStudentById(int id) {
// TODO Auto-generated method stub
}
public List<Student> queryAllStudent() {
// TODO Auto-generated method stub
List<Student> studentList=null;
try {
studentList=sqlMapClient.queryForList(arg0, arg1)
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return studentList;
}
public Student queryStudentById(int id) {
// TODO Auto-generated method stub
return null;
}
public List<Student> queryStudentByName(String name) {
// TODO Auto-generated method stub
return null;
}
public void updateStudent(Student student) {
// TODO Auto-generated method stub
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
StudentDAO dao=new StudentDAOImpl();
for(Student student:dao.queryAllStudent()){
System.out.println(student);
}
}
}
[解决办法]
错误代码呢?