熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java開源技術 >> 正文

Spring 通過JDBC配置數據庫

2022-06-13   來源: Java開源技術 

XXXdataxml: 
<bean id=dataSource
  class=orgspringframeworkjdbcdatasourceDriverManagerDataSource>
  <property name=driverClassName>
   <value>${jdbcdriverClassName}</value>
  </property>
  <property name=url>
   <value>${jdbcurl}</value>
  </property>
  <property name=username>
   <value>${jdbcusername}</value>
  </property>
  <property name=password>
   <value>${jdbcpassword}</value>
  </property>
 </bean>
 
applicationContextxml:
 <bean id=propertyConfigurer
  class=orgspringframewonfigPropertyPlaceholderConfigurer>
  <property name=locations>
   <list>
    <value>classpath:jdbcproperties</value>
   </list>
  </property>
 </bean>
 
 
jdbcproperties:
jdbcdriverClassName=oraclejdbcdriverOracleDriver
jdbcurl=jdbc:oracle:thin:@::dbname
jdbcusername=username
jdbcpassword=password
From:http://tw.wingwit.com/Article/program/Java/ky/201311/27912.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.