这个怎么初始化呢。比如 public class TestSI extends SqlMapClientDaoSupport {
public List getProduct(String productId) throws DataAccessException { // List list = this.getSqlMapClientTemplate().queryForList("selectAllStudent"); Student student = (Student) getSqlMapClientTemplate().queryForObject("Student.selectbyid",1); // for(int i = 0 ; i < list.size() ; i ++){ // System.out.println(); // } return null; } public static void main(String[] args){ TestSI dao = new TestSI(); dao.getProduct("1"); }
应该用spring框架来初始化
public List getProduct(String productId) throws DataAccessException {
// List list = this.getSqlMapClientTemplate().queryForList("selectAllStudent");
Student student = (Student) getSqlMapClientTemplate().queryForObject("Student.selectbyid",1);
// for(int i = 0 ; i < list.size() ; i ++){
// System.out.println();
// }
return null;
}
public static void main(String[] args){
TestSI dao = new TestSI();
dao.getProduct("1");
}
}
这个方法如何修改,谢谢
这里还需要配置一下datasource的
同时还要配置datasource希望对你有帮助
我给你一个例子:
<bean id="sqlMapClient"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocations">
<list>
<value>classpath:_ibatis/SqlMapConfig.xml</value>
</list>
</property>
<property name="dataSource">
<ref bean="dataSource"/>
</property>
</bean>