Hibernate不能即時擷取MySQL資料庫的更新

來源:互聯網
上載者:User

標籤:hibernate   c3p0   mysql   資料庫更新   無法擷取更新後的資料   

最近項目中使用到了Hibernate,但每次資料庫記錄有更新後,用hibernate無法尋找到更新後的資料。網上尋找了許多教程,最終發現通過更改hibernate的預設串連池可以解決。通過使用c3p0串連池,替換掉hibernate的預設串連池後,就可以尋找到MySQL更新後的資料了。

具體修改方法如下:

在hibernate.cfg.xml設定檔中,增加以下內容:

 <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>                <property name="hibernate.c3p0.max_size">20</property>  <!-- 在串連池中可用資料庫連接的最大數目-->                <property name="hibernate.c3p0.min_size">5</property>  <!-- 在串連池中可用資料庫連接的最小數目-->                <property name="hibernate.c3p0.max_statements">100</property>                <property name="hibernate.c3p0.idle_test_period">120</property>                <property name="hibernate.c3p0.acquire_increment">1</property>                <property name="c3p0.testConnectionOnCheckout">true</property>                <property name="c3p0.idleConnectionTestPeriod">18000</property>                <property name="c3p0.maxIdleTime">25000</property>

附上c3p0的jar包,:http://download.csdn.net/detail/until_v/8149191

Hibernate不能即時擷取MySQL資料庫的更新

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.