1.在spring.xml 中 配置
<bean id="jdbcTemplate"
class="org.springframework.jdbc.core.JdbcTemplate" abstract="false"
lazy-init="false" autowire="default" dependency-check="default">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
2. public static void main(String[] args) {
Resource resource = new ClassPathResource("spring/spring-core.xml");
BeanFactory factory = new XmlBeanFactory(resource);
JdbcTemplate jt = (JdbcTemplate)factory.getBean("jdbcTemplate");
String userName = "lick";
String sql = "select username,password from t_cprt_user where username = '" + userName +"';";
jt.execute(sql);
System.out.println(jt.queryForList(sql).get(0));
Map map = jt.queryForMap(sql);
System.out.println(map.get("USERNAME"));
System.out.println(map.get("PASSWORD"));
}