fufengrui 2012-03-29 10:03
浏览 1176
已采纳

虚拟主机上,hibernate的连接池如何配置

有这方面经验的,希望能指导一下,最好能给出C3PO的配置,或者proxool的配置,如果能解决,分数全部奉上,谢谢:

下面的配置不行,而且修改了几个类似参数也不行,最好能说明原因

20

5

120

100

120

2

true

这个也不行:
<?xml version="1.0" encoding="utf-8"?>





pool1

jdbc:mysql://mysql5-g4.xincache.cn/net87731018?userUnicode=true&characterEncoding=utf-8

com.mysql.jdbc.Driver







10000

10

0

10

0

10000

true

select CURRENT_DATE



用正常的jdbc能登陆上也能连接上,用hibernate不行,有时候报SELECT command denied to user 之类的的异常,提示没有权限,有时候报什么异常,我还得测测

附虚拟主机的mysql参数:

auto increment increment 1

auto increment offset 1

automatic sp privileges ON

back log 50

basedir /usr/local/mysql5/

binlog cache size 32,768

bulk insert buffer size 8,388,608

character set client utf8

(全局值) gbk

character set connection utf8

(全局值) gbk

character set database gbk

character set filesystem binary

character set results utf8

(全局值) gbk

character set server gbk

character set system utf8

character sets dir /usr/local/mysql5/share/mysql/charsets/

collation connection utf8_general_ci

(全局值) gbk_chinese_ci

collation database gbk_chinese_ci

collation server gbk_chinese_ci

completion type 0

concurrent insert 1

connect timeout 5

datadir /home/mysqldb/var/

date format %Y-%m-%d

datetime format %Y-%m-%d %H:%i:%s

default week format 0

delay key write ON

delayed insert limit 100

delayed insert timeout 300

delayed queue size 1,000

div precision increment 4

engine condition pushdown OFF

expire logs days 0

flush OFF

flush time 0

ft boolean syntax + -><()~*:""&|

ft max word len 84

ft min word len 4

ft query expansion limit 20

ft stopword file (built-in)

group concat max len 1,024

have archive NO

have bdb NO

have blackhole engine NO

have compress YES

have crypt YES

have csv NO

have dynamic loading NO

have example engine NO

have federated engine NO

have geometry YES

have innodb YES

have isam NO

have merge engine YES

have ndbcluster NO

have openssl NO

have ssl NO

have query cache YES

have raid NO

have rtree keys YES

have symlink YES

hostname IDC-D-1918

init connect

init file

init slave

innodb additional mem pool size 1,048,576

innodb autoextend increment 8

innodb buffer pool awe mem mb 0

innodb buffer pool size 8,388,608

innodb checksums ON

innodb commit concurrency 0

innodb concurrency tickets 500

innodb data file path ibdata1:10M:autoextend

innodb data home dir

innodb doublewrite ON

innodb fast shutdown 1

innodb file io threads 4

innodb file per table OFF

innodb flush log at trx commit 1

innodb flush method

innodb force recovery 0

innodb lock wait timeout 50

innodb locks unsafe for binlog OFF

innodb log arch dir

innodb log archive OFF

innodb log buffer size 1,048,576

innodb log file size 5,242,880

innodb log files in group 2

innodb log group home dir ./

innodb max dirty pages pct 90

innodb max purge lag 0

innodb mirrored log groups 1

innodb open files 300

innodb rollback on timeout OFF

innodb support xa ON

innodb sync spin loops 20

innodb table locks ON

innodb thread concurrency 8

innodb thread sleep delay 10,000

interactive timeout 28,800

join buffer size 131,072

key buffer size 536,870,912

key cache age threshold 300

key cache block size 1,024

key cache division limit 100

language /usr/local/mysql5/share/mysql/english/

large files support ON

large page size 0

large pages OFF

lc time names en_US

license GPL

local infile ON

locked in memory OFF

log OFF

log bin OFF

log bin trust function creators OFF

log error

log queries not using indexes OFF

log slave updates OFF

log slow queries ON

log warnings 1

long query time 10

low priority updates OFF

lower case file system OFF

lower case table names 0

max allowed packet 1,047,552

max binlog cache size 4,294,967,295

max binlog size 1,073,741,824

max connect errors 10

max connections 800

max delayed threads 20

max error count 64

max heap table size 16,777,216

max insert delayed threads 20

max join size 4,294,967,295

max length for sort data 1,024

max prepared stmt count 16,382

max relay log size 0

max seeks for key 4,294,967,295

max sort length 1,024

max sp recursion depth 0

max tmp tables 32

max user connections 20

max write lock count 4,294,967,295

multi range count 256

myisam data pointer size 6

myisam max sort file size 2,147,483,647

myisam recover options OFF

myisam repair threads 1

myisam sort buffer size 67,108,864

myisam stats method nulls_unequal

net buffer length 16,384

net read timeout 30

net retry count 10

net write timeout 60

new OFF

old passwords OFF

open files limit 65,536

optimizer prune level 1

optimizer search depth 62

pid file /home/mysqldb/var/IDC-D-1918.pid

port 3,306

preload buffer size 32,768

profiling OFF

profiling history size 15

protocol version 10

query alloc block size 8,192

query cache limit 1,048,576

query cache min res unit 4,096

query cache size 67,108,864

query cache type ON

query cache wlock invalidate OFF

query prealloc size 8,192

range alloc block size 2,048

read buffer size 2,093,056

read only OFF

read rnd buffer size 262,144

relay log purge ON

relay log space limit 0

rpl recovery rank 0

secure auth OFF

secure file priv

server id 1

skip external locking ON

skip networking OFF

skip show database OFF

slave compressed protocol OFF

slave load tmpdir /tmp/

slave net timeout 3,600

slave skip errors OFF

slave transaction retries 10

slow launch time 2

socket /tmp/mysql.sock

sort buffer size 4,194,296

sql big selects ON

sql mode

sql notes ON

sql warnings OFF

ssl ca

ssl capath

ssl cert

ssl cipher

ssl key

storage engine MyISAM

sync binlog 0

sync frm ON

system time zone CST

table cache 2,048

table lock wait timeout 50

table type MyISAM

thread cache size 8

thread stack 196,608

time format %H:%i:%s

time zone SYSTEM

timed mutexes OFF

tmp table size 33,554,432

tmpdir /tmp/

transaction alloc block size 8,192

transaction prealloc size 4,096

tx isolation REPEATABLE-READ

updatable views with limit YES

version 5.0.45-log

version comment Source distribution

version compile machine i686

version compile os pc-linux-gnu

wait timeout 10

  • 写回答

1条回答 默认 最新

  • iteye_9444 2012-03-29 10:39
    关注

    不知道你是否用的spring,我给个hibernate和spring 的c3p0配置:

       < bean id = "dataSource" class = "com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close" > 
              < property name = "driverClass" value = "com.mysql.jdbc.Driver" /> 
              < property name = "jdbcUrl" value = "jdbc:mysql://127.0.0.1/test" /> 
              < property name = "user" value = "root" /> 
              < property name = "password" value = "root" /> 
    
              <!-- 当连接池中的连接用完时, c3p0 一次性创建连接的数目 --> 
              < property name = "acquireIncrement" value = "5" /> 
    
              <!-- 定义从数据库获取新连接失败后重复尝试获取连接的次数,默认为 30 --> 
              < property name = "acquireRetryAttempts" value = "30" /> 
    
              <!-- 定义两次连接中间隔的时间,单位毫秒,默认为 1000 --> 
              < property name = "acquireRetryDelay" value = "1000" /> 
              < property name = "idleConnectionTestPeriod" value = "3000" /> 
    
              <!-- 当连接池用完时客户端调用 getConnection() 后等待获取新连接的时间, 
              超时后将抛出 SQLException ,如设为 0 则无限期等待。单位毫秒,默认为 0 ;   --> 
              < property name = "checkoutTimeout"   value = "3000" /> 
              < property name = "maxPoolSize" value = "80" /> 
              < property name = "minPoolSize" value = "1" /> 
    
              <!-- JDBC 的标准参数,用以控制数据源内加载的 PreparedStatement 数量。 
              但由于预缓存的 Statement 属 于单个 Connection 而不是整个连接池。 
              所以设置这个参数需要考虑到多方面的因素,如果 maxStatements 与 
              maxStatementsPerConnection 均为 0 ,则缓存被关闭。默认为 0 ; 
                --> 
              < property name = "maxStatements" value = "6000" /> 
              < property name = "initialPoolSize" value = "5" /> 
    

    </ bean >

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?