当我尝试将 Spring JDBC Template 与 JSF/ICEFaces 一起使用时,它会引发一些错误。
这是我的spring.xml
<beans ...>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@//localhost:1521/xe" />
<property name="username" value="hr" />
<property name="password" value="hr" />
</bean>
<bean id="testDAO" class="com.sura2k.TestDAOImpl">
<property name="dataSource" ref="dataSource" />
</bean>
</beans>
这是DAO。
public class TestDAOImpl extends JdbcDaoSupport implements TestDAO {
@Override
public int getTotal(){
String sql = "SELECT COUNT(*) FROM CUSTOMER";
int total = getJdbcTemplate().queryForInt(sql);
return total;
}
}
例外...
....
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'dataSource' defined in class path resource
[META-INF/database/spring.datasource.xml]: Error setting property values;
nested exception is org.springframework.beans.PropertyBatchUpdateException;
nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException:
Property 'driverClassName' threw exception; nested exception is
java.lang.IllegalStateException: Could not load JDBC driver class
[oracle.jdbc.driver.OracleDriver]
...