怎樣在hibernate中使用資料庫連線池

2021-04-12 21:26:06 字數 1036 閱讀 2187

經過乙個週末的折騰,終於找到了hibernate中使用資料庫連線池的解決方案。

從網上google了一下,發現大致有三種可以實施的解決方案:

1、使用hibernate自帶的連線池;

2、使用c**o包的連線池功能;

3、使用proxool包的連線池功能;

第一種方案,就是在myeclipse產生的hibernate.cfg.xml中新增乙個屬性:

20第二種方案是:

test

com.microsoft.jdbc.sqlserver.sqlserverdriver

jdbc:microsoft:sqlserver://localhost:1433;databasename=test

sa123210

180041

36000210

1200302

org.hibernate.connection.c**0connectionprovider

第三中方案是proxool:

在hibernate.cfg.xml中新增:

org.hibernate.connection.proxoolconnectionprovider

dbpool

proxool.xml

org.hibernate.dialect.sqlserverdialect

false

然後再新增乙個proxool.xml檔案:

<?xml version="1.0" encoding="utf-8"?>

anything outside the "proxool" tag is ignored. -->

dbpool

jdbc:microsoft:sqlserver://localhost:1433;databasename=test

com.microsoft.jdbc.sqlserver.sqlserverdriver

10這個三種方案,我都可以配置成功,可是,鬱悶的是,這三種方案,都比我不用連線池的資料要慢,可能是我的測試不準確吧?我只做了連續100000次的資料插入操作。

怎樣在hibernate中使用資料庫連線池

經過乙個週末的折騰,終於找到了hibernate中使用資料庫連線池的解決方案。從網上google了一下,發現大致有三種可以實施的解決方案 1 使用hibernate自帶的連線池 2 使用c3po包的連線池功能 3 使用proxool包的連線池功能 第一種方案,就是在myeclipse產生的hiber...

在Eclipse中使用Hibernate 四

產生資料庫中的表 很清楚,你可以用hibernate synchronizer來做靈巧的事情。我會在我自己的hibernate專案中使用該外掛程式嗎?這個想法有其它一些優缺點需要考慮,可能現在還不是做決定的時候,直到需要用hibernate來取代自家釀 當然非常簡單 的 已經在工作的輕量級o r工具...

在Java SE中使用Hibernate處理資料

hibernate.dialect net.sf.hibernate.dialect.postgresqldialect hibernate.connection.driver class org.postgresql.driver hibernate.connection.url jdbc pos...