Spring 資料來源配置
阿新 • • 發佈:2018-12-28
Oracle
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close"
p:driverClassName="oracle.jdbc.driver.OracleDriver"
p:url="jdbc:oracle:thin:@localhost:1521:orcl"
p:username="sample"
p:password="mypassword" />
SqlServer
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" p:driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" p:url=" jdbc:sqlserver://localhost:1433;DatabaseName=sample" p:username="sample" p:password="mypassword" />
MySQL
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close"
p:driverClassName="com.mysql.jdbc.Driver"
p:url="jdbc:mysql://localhost:3306/sampledb"
p:username="root"
p:password="123456" />
DB2
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" p:driverClassName="com.ibm.db2.jcc.DB2Driver" p:url="jdbc:db2://localhost:50000/sample" p:username="sample" p:password="mypassword" />