zoukankan
html css js c++ java
利用c3p0配置数据库连接
利用c3p0配置数据库连接
一.连接mysql数据库
<
bean
id
="dataSource"
class
="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method
="close"
abstract
="false"
singleton
="true"
lazy-init
="default"
autowire
="default"
dependency-check
="default"
>
<
property
name
="driverClass"
>
<
value
>
com.mysql.jdbc.Driver
</
value
>
</
property
>
<
property
name
="jdbcUrl"
>
<
value
>
jdbc:mysql://192.168.0.1/databasename?useUnicode=true
&
characterEncoding=utf-8
&
autoReconnect=true
</
value
>
</
property
>
<
property
name
="user"
>
<
value
>
username
</
value
>
</
property
>
<
property
name
="password"
>
<
value
>
password
</
value
>
</
property
>
<
property
name
="minPoolSize"
>
<
value
>
10
</
value
>
</
property
>
<
property
name
="maxPoolSize"
>
<
value
>
20
</
value
>
</
property
>
<
property
name
="initialPoolSize"
>
<
value
>
10
</
value
>
</
property
>
</
bean
>
<
bean
id
="sessionFactory"
class
="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
>
<
property
name
="dataSource"
>
<
ref
bean
="dataSource"
></
ref
>
</
property
>
<
property
name
="hibernateProperties"
>
<
props
>
<
prop
key
="hibernate.dialect"
>
org.hibernate.dialect.MySQLDialect
</
prop
>
<
prop
key
="hibernate.show_sql"
>
false
</
prop
>
<
prop
key
="hibernate.generate_statistics"
>
true
</
prop
>
<
prop
key
="hibernate.cache.use_query_cache"
>
true
</
prop
>
<
prop
key
="hibernate.cache.use_second_level_cache"
>
true
</
prop
>
<
prop
key
="hibernate.cache.provider_class"
>
net.sf.ehcache.hibernate.EhCacheProvider
</
prop
>
<
prop
key
="hibernate.connection.provider_class"
>
org.hibernate.connection.C3P0ConnectionProvider
</
prop
>
<
prop
key
="hibernate.query.substitutions"
>
true 1, false 0, yes 'Y', no 'N'
</
prop
>
<
prop
key
="hibernate.bytecode.use_reflection_optimizer"
>
true
</
prop
>
<
prop
key
="hibernate.use_outer_join"
>
true
</
prop
>
<
prop
key
="hibernate.prepare_sql"
>
true
</
prop
>
<
prop
key
="hibernate.query.factory_class"
>
org.hibernate.hql.ast.ASTQueryTranslatorFactory
</
prop
>
</
props
>
</
property
>
<
property
name
="mappingResources"
>
<
list
>
<
value
>
xxx/xx/xx.hbm.xml
</
value
>
<
value
>
xxx/xx/xx.hbm.xml
</
value
>
</
list
>
</
property
>
</
bean
>
二.连接Oracle数据库
<
bean
id
="dataSource"
class
="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method
="close"
abstract
="false"
singleton
="true"
lazy-init
="default"
autowire
="default"
dependency-check
="default"
>
<
property
name
="driverClass"
>
<
value
>
oracle.jdbc.driver.OracleDriver
</
value
>
</
property
>
<
property
name
="jdbcUrl"
>
<
value
>
jdbc:oracle:thin:@192.168.0.1:1521:orcl
</
value
>
</
property
>
<
property
name
="user"
>
<
value
>
username
</
value
>
</
property
>
<
property
name
="password"
>
<
value
>
password
</
value
>
</
property
>
<
property
name
="minPoolSize"
>
<
value
>
10
</
value
>
</
property
>
<
property
name
="maxPoolSize"
>
<
value
>
20
</
value
>
</
property
>
<
property
name
="initialPoolSize"
>
<
value
>
10
</
value
>
</
property
>
</
bean
>
<
bean
id
="sessionFactory"
class
="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
>
<
property
name
="dataSource"
>
<
ref
bean
="dataSource"
></
ref
>
</
property
>
<
property
name
="hibernateProperties"
>
<
props
>
<
prop
key
="hibernate.dialect"
>
org.hibernate.dialect.OracleDialect
</
prop
>
<
prop
key
="hibernate.show_sql"
>
false
</
prop
>
<
prop
key
="hibernate.generate_statistics"
>
true
</
prop
>
<
prop
key
="hibernate.cache.use_query_cache"
>
true
</
prop
>
<
prop
key
="hibernate.cache.use_second_level_cache"
>
true
</
prop
>
<
prop
key
="hibernate.cache.provider_class"
>
net.sf.ehcache.hibernate.EhCacheProvider
</
prop
>
<
prop
key
="hibernate.connection.provider_class"
>
org.hibernate.connection.C3P0ConnectionProvider
</
prop
>
<
prop
key
="hibernate.query.substitutions"
>
true 1, false 0, yes 'Y', no 'N'
</
prop
>
<
prop
key
="hibernate.bytecode.use_reflection_optimizer"
>
true
</
prop
>
<
prop
key
="hibernate.use_outer_join"
>
true
</
prop
>
<
prop
key
="hibernate.prepare_sql"
>
true
</
prop
>
<
prop
key
="hibernate.query.factory_class"
>
org.hibernate.hql.ast.ASTQueryTranslatorFactory
</
prop
>
</
props
>
</
property
>
<
property
name
="mappingResources"
>
<
list
>
<
value
>
xxx/xx/xx.hbm.xml
</
value
>
<
value
>
xxx/xx/xx.hbm.xml
</
value
>
</
list
>
</
property
>
</
bean
>
查看全文
相关阅读:
RabbitMQ资料
在网页打开本地程序的思路
HttpClient的巨坑
webbrowser设置为相应的IE版本
cpupower:Shows and sets processor power related values
golang 国内环境配置
OSX 创建 randisk(或称 tmpfs)
Gentoo 搭遗
ubuntu 去除开机背景
fabric && cita 调研对比
原文地址:https://www.cnblogs.com/hehe520/p/6330273.html
最新文章
Android 判断当前thread 是否是UI thread
Android Handler 的使用
BroPHP使用心得
移动开发方式的讨论
IP_MULTICAST_LOOP
绑定IP 绑定设备
STM32 CAN
ARM CORTEX-M3的时钟
stm8l定时器中的ARPE
如何设置路由器的MTU
热门文章
VLAN
指定PING的网卡
STM32定时器的两个小难点
windows枚举串口
ilasm修改源码
性能优化的最一般手段
CentOS7安装vncserver
The clickjacking attack
minikube start 使用Hyper-V
博客地址
Copyright © 2011-2022 走看看