怎么使用JDBC连接SQL Server
1个回答
2016-07-18 · 做真实的自己 用良心做教育
千锋教育
千锋教育专注HTML5大前端、JavaEE、Python、人工智能、UI&UE、云计算、全栈软件测试、大数据、物联网+嵌入式、Unity游戏开发、网络安全、互联网营销、Go语言等培训教育。
向TA提问
关注
展开全部
properties中的配置:
jdbc.baseresource.driver=net.sourceforge.jtds.jdbc.Driver
jdbc.baseresource.url=jdbc:jtds:sqlserver://172.16.91.115:1433;databaseName=BasereSource
jdbc.baseresource.username=sa
jdbc.baseresource.password=sasa
applicationContext.xml中的配置:
<!-- Base库的配置 -->
<bean id="baseResourceDataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.baseresource.driver}" />
<property name="url" value="${jdbc.baseresource.url}" />
<property name="username" value="${jdbc.baseresource.username}" />
<property name="password" value="${jdbc.baseresource.password}" />
<property name="maxActive" value="20" />
<property name="maxIdle" value="5" />
<property name="defaultAutoCommit" value="true" />
<property name="minEvictableIdleTimeMillis" value="3600000" />
<property name="testWhileIdle" value="true" />
<property name="testOnBorrow" value="false" />
<property name="testOnReturn" value="false" />
<property name="validationQuery" value="select getdate()" />
<property name="validationQueryTimeout" value="1" />
<property name="timeBetweenEvictionRunsMillis" value="3000" />
<property name="numTestsPerEvictionRun" value="5" />
<property name="maxWait" value="60000" />
<property name="removeAbandoned" value="true" />
<property name="removeAbandonedTimeout" value="180" />
</bean>
jdbc.baseresource.driver=net.sourceforge.jtds.jdbc.Driver
jdbc.baseresource.url=jdbc:jtds:sqlserver://172.16.91.115:1433;databaseName=BasereSource
jdbc.baseresource.username=sa
jdbc.baseresource.password=sasa
applicationContext.xml中的配置:
<!-- Base库的配置 -->
<bean id="baseResourceDataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.baseresource.driver}" />
<property name="url" value="${jdbc.baseresource.url}" />
<property name="username" value="${jdbc.baseresource.username}" />
<property name="password" value="${jdbc.baseresource.password}" />
<property name="maxActive" value="20" />
<property name="maxIdle" value="5" />
<property name="defaultAutoCommit" value="true" />
<property name="minEvictableIdleTimeMillis" value="3600000" />
<property name="testWhileIdle" value="true" />
<property name="testOnBorrow" value="false" />
<property name="testOnReturn" value="false" />
<property name="validationQuery" value="select getdate()" />
<property name="validationQueryTimeout" value="1" />
<property name="timeBetweenEvictionRunsMillis" value="3000" />
<property name="numTestsPerEvictionRun" value="5" />
<property name="maxWait" value="60000" />
<property name="removeAbandoned" value="true" />
<property name="removeAbandonedTimeout" value="180" />
</bean>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询