• spring连接数据库配置


    Spring 数据库连接配置

    一 ORACLE
       <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
    <property name="url" value="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.101)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=orcl)(SERVER=DEDICATED)))" />
    <property name="username" value="rootl" />
    <property name="password" value="1234" />
    </bean>
    二 DB2
       <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="com.ibm.db2.jdbc.app.DB2Driver" />
    <property name="url" value="jdbc:db2:thin:@localhost:5000/testDB" />
    <property name="username" value="rootl" />
    <property name="password" value="1234" />
    </bean>
    三 SQL Server
       <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="com.microsoft.jdbc.sqlserver.SQLServerDriver" />
    <property name="url" value="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName = testDB" />
    <property name="username" value="rootl" />
    <property name="password" value="1234" />
    </bean>
    三 MySQL
       <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="org.postgresql.Driver" />
    <property name="url" value="jdbc:postgresql://localhost/ testDB" />
    <property name="username" value="rootl" />
    <property name="password" value="1234" />
    </bean>

    org.apache.commons.dbcp.BasicDataSource 需要commons-pool.jar,commons-dbcp-1.2.2.jar,commons-collections-3.2.jar三个JAR包


    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    <bean id="dataSourceJDBC"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName">
    <value>COM.ibm.db2.jdbc.app.DB2Driver</value>
    </property>
    <property name="url">
    <value>jdbc:db2:testDB</value>
    </property>
    <property name="username">
    <value>dsw</value>
    </property>
    <property name="password">
    <value>pass4spring</value>
    </property>
    </bean>
    <bean id="SearchImpl" class="com.springsproc.dao.jdbc.SearchDAOImpl">
    <property name="dataSource">
    <ref local="dataSourceJDBC" />
    </property>
    <property name="sprocName">
    <value>DSW.S_CUSTOMER</value>
    </property>
    </bean>
    </beans>

  • 相关阅读:
    POJ 1739 Tony's Tour(插头DP)
    POJ 1741 Tree(树的分治)
    POJ 1655 Balancing Act(求树的重心)
    POJ 2631 Roads in the North(求树的直径,两次遍历 or 树DP)
    codeforces 359E Neatness(DFS+构造)
    codeforces 295C Greg and Friends(BFS+DP)
    codeforces 228E The Road to Berland is Paved With Good Intentions(2-SAT)
    Eclipse 代码提示功能设置。
    svn 清空
    android 线程
  • 原文地址:https://www.cnblogs.com/vitosun/p/3727122.html
Copyright © 2020-2023  润新知