首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

Struts+Spring+Hibernate连接数据库的三个步骤

2012-12-19 
Struts+Spring+Hibernate连接数据库的三个方法Struts+Spring+Hibernate连接数据库的三个方法第一种在Sprin

Struts+Spring+Hibernate连接数据库的三个方法

Struts+Spring+Hibernate连接数据库的三个方法第一种在Spring applicationContext.xml中连接: <bean id="dataSource" destroy-method="close">        <property name="driverClassName">            <value>oracle.jdbc.driver.OracleDriver</value>        </property>        <property name="url">            <value>jdbc:oracle:thin:@localhost:1521:test</value>        </property>               <property name="username">            <value>cpiclh</value>        </property>        <property name="password">            <value>cpiclh</value>        </property>   </bean>     <bean id="sessionFactory" />        </property>        <property name="mappingResources">              <list>                  <value>com/Hibernate/Pojo/FactUsers.hbm.xml</value>              </list>          </property>        <property name="hibernateProperties">            <props>                <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>                <prop key="hibernate.show_sql">true</prop>            </props>        </property>   </bean>  第二种在Hibernate hibernate.cfg.xml中连接: <session-factory>            <property name="connection.username">root</property>            <property name="connection.url">                jdbc:oracle:thin:@192.168.0.1:1521:test            </property>            <property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>                       <property name="connection.password">root</property>            <property name="connection.driver_class">                oracle.jdbc.driver.OracleDriver            </property>            <mapping resource="com/hibernate/pojo/FactUsers.hbm.xml" />        </session-factory>  第三种在Tomcat中的 apache-tomcat-5.5.17\conf\Catalina目录下放一个 和目录同名的XML,内容如下 <Context path="" docBase="ROOT">        <Resource name="jdbc/db" auth="Container" type="javax.sql.DataSource" removeAbandoned="true" removeAbandonedTimeout="60"                  username="root" password="root" driverClassName="oracle.jdbc.driver.OracleDriver"                  url="jdbc:oracle:thin:@192.168.0.1:1521:test"/>   </Context> 

热点排行