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
>
查看全文
相关阅读:
flask 本地局域网连接
python
Python 有关网址
Python 字典(Dictionary)操作详解
Elasticsearch集成HanLP分词器-个人学习
知识图谱构建
项目实战:如何构建知识图谱
10分钟上手图数据库Neo4j
知识图谱技术原理介绍
知识图谱的应用
原文地址:https://www.cnblogs.com/hehe520/p/6330273.html
最新文章
JAVA的Proxy动态代理在自动化测试中的应用
JAVA Builder模式构建MAP/LIST的示例
HttpClient在HTTP协议接口测试中的使用
JAVA中取子字符串的几种方式
JAVA自已设计JSON解析器
flex
webpack
promise 总结
js 继承
跨域
热门文章
原型
原型继承和类式继承
react问题You must install peer dependencies yourself.
react 核心技术点
SqlServer对select * from (select *from table) 支持
excel表格 只显示公式不显示结果 双击单元格后才显示结果
UniGUI介绍
FastReport ReportSummary 中 Sum、Count等聚合函数用法
显示窗口是活动窗口顺序出现的问题
delphi 控件没有即使更新相关的数据问题
Copyright © 2011-2022 走看看