hibernate 怎么连接oracle数据库,在hibernate.cfg.xml 里怎么配置

解决方案 »

  1.   

    applicationContext-kpi.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:lang="http://www.springframework.org/schema/lang"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
                        http://www.springframework.org/schema/beans/spring-beans-2.0.xsd 
                        http://www.springframework.org/schema/lang 
                        http://www.springframework.org/schema/lang/spring-lang-2.0.xsd"
    default-autowire="byName">
     
      <bean id="kpiDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
          <property name="driverClass">
            <value>oracle.jdbc.OracleDriver</value>
          </property>
          <property name="jdbcUrl">
            <value>jdbc:oracle:thin:@192.168.1.29:1521:orcl</value>
          </property>
          <property name="user">
           <value>kpi</value>
          </property>
          <property name="password">
           <value>kpi</value>
          </property>
          <property name="initialPoolSize"><value>10</value></property>
          <property name="minPoolSize"><value>5</value></property>
          <property name="maxPoolSize"><value>30</value></property>
          <property name="acquireIncrement"><value>5</value></property>
          <property name="maxIdleTime"><value>10</value></property>
          <property name="maxStatements"><value>0</value></property>
        </bean>
     
     
    <!-- Hibernate3 -->
    <bean id="hbSessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="kpiDataSource" />
    <property name="configLocations">
    <value>classpath:hibernate-kpi.cfg.xml</value>
    </property>
    <!-- property name="lobHandler" ref="defaultLobHandler" /-->
    </bean> <!-- Hibernate Transaction -->
    <bean id="kpiTxHBManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="hbSessionFactory" />
    </bean>

    <!--bean id="defaultLobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true" /-->

    </beans>
      

  2.   

    jdbc:oracle:thin:@192.168.1.29:1521:orcl
    thin  是必须的吗?
    orcl  是数据库吧