您的位置:首页 > 编程语言 > Java开发

使用Spring的jdbcTemplate进一步简化JDBC操作

2013-08-15 22:36 621 查看
先看applicationContext.xml配置文件:

Code

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <bean id="springDSN"

class="org.springframework.jdbc.datasource.DriverManagerDataSource">

<property name="driverClassName"

value="com.microsoft.jdbc.sqlserver.SQLServerDriver">

</property>

<property name="url"

value="jdbc:microsoft:sqlserver://localhost:1433;databasename=bbs">

</property>

<property name="username" value="sa"></property>

<property name="password" value="sa"></property>

</bean>
<bean id="jdbcTemplate"

class="org.springframework.jdbc.core.JdbcTemplate" abstract="false"

lazy-init="false" autowire="default" dependency-check="default">

<property name="dataSource">

<ref bean="springDSN" />

</property>

</bean>

</beans>

在看SpringUtil类




Code

发表评论
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: