﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-海水正蓝-随笔分类-Hibernate</title><link>http://www.blogjava.net/xiaohuzi2008/category/53816.html</link><description>面朝大海，春暖花开</description><language>zh-cn</language><lastBuildDate>Wed, 14 Aug 2013 01:31:32 GMT</lastBuildDate><pubDate>Wed, 14 Aug 2013 01:31:32 GMT</pubDate><ttl>60</ttl><item><title>Hibernate配置文件中配置各种数据库的driver、URL </title><link>http://www.blogjava.net/xiaohuzi2008/archive/2013/08/14/402770.html</link><dc:creator>小胡子</dc:creator><author>小胡子</author><pubDate>Wed, 14 Aug 2013 01:29:00 GMT</pubDate><guid>http://www.blogjava.net/xiaohuzi2008/archive/2013/08/14/402770.html</guid><wfw:comment>http://www.blogjava.net/xiaohuzi2008/comments/402770.html</wfw:comment><comments>http://www.blogjava.net/xiaohuzi2008/archive/2013/08/14/402770.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaohuzi2008/comments/commentRss/402770.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaohuzi2008/services/trackbacks/402770.html</trackback:ping><description><![CDATA[<div><p>hibernate.properties</p> <p>######################<br />### Query Language ###<br />######################</p> <p>## define query language constants / function names</p> <p>hibernate.query.substitutions yes 'Y', no 'N'</p> <p><br />## select the classic query parser</p> <p>#hibernate.query.factory_class org.hibernate.hql.classic.ClassicQueryTranslatorFactory</p> <p><br />#################<br />### Platforms ###<br />#################</p> <p>## JNDI Datasource</p> <p>#hibernate.connection.datasource jdbc/test<br />#hibernate.connection.username db2<br />#hibernate.connection.password db2</p> <p><br />## HypersonicSQL</p> <p>hibernate.dialect org.hibernate.dialect.HSQLDialect<br />hibernate.connection.driver_class org.hsqldb.jdbcDriver<br />hibernate.connection.username sa<br />hibernate.connection.password<br />hibernate.connection.url jdbc:hsqldb:./build/db/hsqldb/hibernate<br />#hibernate.connection.url jdbc:hsqldb:hsql://localhost<br />#hibernate.connection.url jdbc:hsqldb:test</p> <p>## H2 (www.h2database.com)<br />#hibernate.dialect org.hibernate.dialect.H2Dialect<br />#hibernate.connection.driver_class org.h2.Driver<br />#hibernate.connection.username sa<br />#hibernate.connection.password<br />#hibernate.connection.url jdbc:h2:mem:./build/db/h2/hibernate<br />#hibernate.connection.url jdbc:h2:testdb/h2test<br />#hibernate.connection.url jdbc:h2:mem:imdb1<br />#hibernate.connection.url jdbc:h2:tcp://dbserv:8084/sample; <br />#hibernate.connection.url jdbc:h2:ssl://secureserv:8085/sample; <br />#hibernate.connection.url jdbc:h2:ssl://secureserv/testdb;cipher=AES</p> <p>## MySQL</p> <p>#hibernate.dialect org.hibernate.dialect.MySQLDialect<br />#hibernate.dialect org.hibernate.dialect.MySQLInnoDBDialect<br />#hibernate.dialect org.hibernate.dialect.MySQLMyISAMDialect<br />#hibernate.connection.driver_class com.mysql.jdbc.Driver<br />#hibernate.connection.url jdbc:mysql:///test<br />#hibernate.connection.username gavin<br />#hibernate.connection.password</p> <p><br />## Oracle</p> <p>#hibernate.dialect org.hibernate.dialect.OracleDialect<br />#hibernate.dialect org.hibernate.dialect.Oracle9Dialect<br />#hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver<br />#hibernate.connection.username ora<br />#hibernate.connection.password ora<br />#hibernate.connection.url jdbc:oracle:thin:@localhost:1521:orcl<br />#hibernate.connection.url jdbc:oracle:thin:@localhost:1522:XE</p> <p><br />## PostgreSQL</p> <p>#hibernate.dialect org.hibernate.dialect.PostgreSQLDialect<br />#hibernate.connection.driver_class org.postgresql.Driver<br />#hibernate.connection.url jdbc:postgresql:template1<br />#hibernate.connection.username pg<br />#hibernate.connection.password</p> <p><br />## DB2</p> <p>#hibernate.dialect org.hibernate.dialect.DB2Dialect<br />#hibernate.connection.driver_class com.ibm.db2.jcc.DB2Driver<br />#hibernate.connection.driver_class COM.ibm.db2.jdbc.app.DB2Driver<br />#hibernate.connection.url jdbc:db2://localhost:50000/somename<br />#hibernate.connection.url jdbc:db2:somename<br />#hibernate.connection.username db2<br />#hibernate.connection.password db2</p> <p>## TimesTen</p> <p>#hibernate.dialect org.hibernate.dialect.TimesTenDialect<br />#hibernate.connection.driver_class com.timesten.jdbc.TimesTenDriver<br />#hibernate.connection.url jdbc:timesten:direct:test<br />#hibernate.connection.username<br />#hibernate.connection.password</p> <p>## DB2/400</p> <p>#hibernate.dialect org.hibernate.dialect.DB2400Dialect<br />#hibernate.connection.username user<br />#hibernate.connection.password password</p> <p>## Native driver<br />#hibernate.connection.driver_class COM.ibm.db2.jdbc.app.DB2Driver<br />#hibernate.connection.url jdbc:db2://systemname</p> <p>## Toolbox driver<br />#hibernate.connection.driver_class com.ibm.as400.access.AS400JDBCDriver<br />#hibernate.connection.url jdbc:as400://systemname</p> <p><br />## Derby (not supported!)</p> <p>#hibernate.dialect org.hibernate.dialect.DerbyDialect<br />#hibernate.connection.driver_class org.apache.derby.jdbc.EmbeddedDriver<br />#hibernate.connection.username<br />#hibernate.connection.password<br />#hibernate.connection.url jdbc:derby:build/db/derby/hibernate;create=true</p> <p><br />## Sybase</p> <p>#hibernate.dialect org.hibernate.dialect.SybaseDialect<br />#hibernate.connection.driver_class com.sybase.jdbc2.jdbc.SybDriver<br />#hibernate.connection.username sa<br />#hibernate.connection.password sasasa<br />#hibernate.connection.url jdbc:sybase:Tds:co3061835-a:5000/tempdb</p> <p><br />## Mckoi SQL</p> <p>#hibernate.dialect org.hibernate.dialect.MckoiDialect<br />#hibernate.connection.driver_class com.mckoi.JDBCDriver<br />#hibernate.connection.url jdbc:mckoi:///<br />#hibernate.connection.url jdbc:mckoi:local://C:/mckoi1.0.3/db.conf<br />#hibernate.connection.username admin<br />#hibernate.connection.password nimda</p> <p><br />## SAP DB</p> <p>#hibernate.dialect org.hibernate.dialect.SAPDBDialect<br />#hibernate.connection.driver_class com.sap.dbtech.jdbc.DriverSapDB<br />#hibernate.connection.url jdbc:sapdb://localhost/TST<br />#hibernate.connection.username TEST<br />#hibernate.connection.password TEST<br />#hibernate.query.substitutions yes 'Y', no 'N'</p> <p><br />## MS SQL Server</p> <p>#hibernate.dialect org.hibernate.dialect.SQLServerDialect<br />#hibernate.connection.username sa<br />#hibernate.connection.password sa</p> <p>## JSQL Driver<br />#hibernate.connection.driver_class com.jnetdirect.jsql.JSQLDriver<br />#hibernate.connection.url jdbc:JSQLConnect://1E1/test</p> <p>## JTURBO Driver<br />#hibernate.connection.driver_class com.newatlanta.jturbo.driver.Driver<br />#hibernate.connection.url jdbc:JTurbo://1E1:1433/test</p> <p>## WebLogic Driver<br />#hibernate.connection.driver_class weblogic.jdbc.mssqlserver4.Driver<br />#hibernate.connection.url jdbc:weblogic:mssqlserver4:1E1:1433</p> <p>## Microsoft Driver (not recommended!)<br />#hibernate.connection.driver_class com.microsoft.jdbc.sqlserver.SQLServerDriver<br />#hibernate.connection.url jdbc:microsoft:sqlserver://1E1;DatabaseName=test;SelectMethod=cursor</p> <p>## The New Microsoft Driver <br />#hibernate.connection.driver_class com.microsoft.sqlserver.jdbc.SQLServerDriver<br />#hibernate.connection.url jdbc:sqlserver://localhost</p> <p>## jTDS (since version 0.9)<br />#hibernate.connection.driver_class net.sourceforge.jtds.jdbc.Driver<br />#hibernate.connection.url jdbc:jtds:sqlserver://1E1/test</p> <p>## Interbase</p> <p>#hibernate.dialect org.hibernate.dialect.InterbaseDialect<br />#hibernate.connection.username sysdba<br />#hibernate.connection.password masterkey</p> <p>## DO NOT specify hibernate.connection.sqlDialect</p> <p>## InterClient</p> <p>#hibernate.connection.driver_class interbase.interclient.Driver<br />#hibernate.connection.url jdbc:interbase://localhost:3060/C:/firebird/test.gdb</p> <p>## Pure Java</p> <p>#hibernate.connection.driver_class org.firebirdsql.jdbc.FBDriver<br />#hibernate.connection.url jdbc:firebirdsql:localhost/3050:/firebird/test.gdb</p> <p><br />## Pointbase</p> <p>#hibernate.dialect org.hibernate.dialect.PointbaseDialect<br />#hibernate.connection.driver_class com.pointbase.jdbc.jdbcUniversalDriver<br />#hibernate.connection.url jdbc:pointbase:embedded:sample<br />#hibernate.connection.username PBPUBLIC<br />#hibernate.connection.password PBPUBLIC</p> <p><br />## Ingres</p> <p>## older versions (before Ingress 2006)</p> <p>#hibernate.dialect org.hibernate.dialect.IngresDialect<br />#hibernate.connection.driver_class ca.edbc.jdbc.EdbcDriver<br />#hibernate.connection.url jdbc:edbc://localhost:II7/database<br />#hibernate.connection.username user<br />#hibernate.connection.password password</p> <p>## Ingres 2006 or later</p> <p>#hibernate.dialect org.hibernate.dialect.IngresDialect<br />#hibernate.connection.driver_class com.ingres.jdbc.IngresDriver<br />#hibernate.connection.url jdbc:ingres://localhost:II7/database;CURSOR=READONLY;auto=multi<br />#hibernate.connection.username user<br />#hibernate.connection.password password</p> <p>## Mimer SQL</p> <p>#hibernate.dialect org.hibernate.dialect.MimerSQLDialect<br />#hibernate.connection.driver_class com.mimer.jdbc.Driver<br />#hibernate.connection.url jdbc:mimer:multi1<br />#hibernate.connection.username hibernate<br />#hibernate.connection.password hibernate</p> <p><br />## InterSystems Cache</p> <p>#hibernate.dialect org.hibernate.dialect.Cache71Dialect<br />#hibernate.connection.driver_class com.intersys.jdbc.CacheDriver<br />#hibernate.connection.username _SYSTEM<br />#hibernate.connection.password SYS<br />#hibernate.connection.url jdbc:Cache://127.0.0.1:1972/HIBERNATE</p> <p><br />#################################<br />### Hibernate Connection Pool ###<br />#################################</p> <p>hibernate.connection.pool_size 1</p> <p><br />###########################<br />### C3P0 Connection Pool###<br />###########################</p> <p>#hibernate.c3p0.max_size 2<br />#hibernate.c3p0.min_size 2<br />#hibernate.c3p0.timeout 5000<br />#hibernate.c3p0.max_statements 100<br />#hibernate.c3p0.idle_test_period 3000<br />#hibernate.c3p0.acquire_increment 2<br />#hibernate.c3p0.validate false</p> <p><br />##############################<br />### Proxool Connection Pool###<br />##############################</p> <p>## Properties for external configuration of Proxool</p> <p>hibernate.proxool.pool_alias pool1</p> <p>## Only need one of the following</p> <p>#hibernate.proxool.existing_pool true<br />#hibernate.proxool.xml proxool.xml<br />#hibernate.proxool.properties proxool.properties</p> <p><br />#################################<br />### Plugin ConnectionProvider ###<br />#################################</p> <p>## use a custom ConnectionProvider (if not set, Hibernate will choose a built-in ConnectionProvider using hueristics)</p> <p>#hibernate.connection.provider_class org.hibernate.connection.DriverManagerConnectionProvider<br />#hibernate.connection.provider_class org.hibernate.connection.DatasourceConnectionProvider<br />#hibernate.connection.provider_class org.hibernate.connection.C3P0ConnectionProvider<br />#hibernate.connection.provider_class org.hibernate.connection.ProxoolConnectionProvider</p> <p><br />#######################<br />### Transaction API ###<br />#######################</p> <p>## Enable automatic flush during the JTA beforeCompletion() callback<br />## (This setting is relevant with or without the Transaction API)</p> <p>#hibernate.transaction.flush_before_completion</p> <p><br />## Enable automatic session close at the end of transaction<br />## (This setting is relevant with or without the Transaction API)</p> <p>#hibernate.transaction.auto_close_session</p> <p><br />## the Transaction API abstracts application code from the underlying JTA or JDBC transactions</p> <p>#hibernate.transaction.factory_class org.hibernate.transaction.JTATransactionFactory<br />#hibernate.transaction.factory_class org.hibernate.transaction.JDBCTransactionFactory</p> <p><br />## to use JTATransactionFactory, Hibernate must be able to locate the UserTransaction in JNDI<br />## default is java:comp/UserTransaction<br />## you do NOT need this setting if you specify hibernate.transaction.manager_lookup_class</p> <p>#jta.UserTransaction jta/usertransaction<br />#jta.UserTransaction javax.transaction.UserTransaction<br />#jta.UserTransaction UserTransaction</p> <p><br />## to use the second-level cache with JTA, Hibernate must be able to obtain the JTA TransactionManager</p> <p>#hibernate.transaction.manager_lookup_class org.hibernate.transaction.JBossTransactionManagerLookup<br />#hibernate.transaction.manager_lookup_class org.hibernate.transaction.WeblogicTransactionManagerLookup<br />#hibernate.transaction.manager_lookup_class org.hibernate.transaction.WebSphereTransactionManagerLookup<br />#hibernate.transaction.manager_lookup_class org.hibernate.transaction.OrionTransactionManagerLookup<br />#hibernate.transaction.manager_lookup_class org.hibernate.transaction.ResinTransactionManagerLookup</p> <p><br />##############################<br />### Miscellaneous Settings ###<br />##############################</p> <p>## print all generated SQL to the console</p> <p>#hibernate.show_sql true</p> <p><br />## format SQL in log and console</p> <p>hibernate.format_sql true</p> <p><br />## add comments to the generated SQL</p> <p>#hibernate.use_sql_comments true</p> <p><br />## generate statistics</p> <p>#hibernate.generate_statistics true</p> <p><br />## auto schema export</p> <p>#hibernate.hbm2ddl.auto create-drop<br />#hibernate.hbm2ddl.auto create<br />#hibernate.hbm2ddl.auto update<br />#hibernate.hbm2ddl.auto validate</p> <p><br />## specify a default schema and catalog for unqualified tablenames</p> <p>#hibernate.default_schema test<br />#hibernate.default_catalog test</p> <p><br />## enable ordering of SQL UPDATEs by primary key</p> <p>#hibernate.order_updates true</p> <p><br />## set the maximum depth of the outer join fetch tree</p> <p>hibernate.max_fetch_depth 1</p> <p><br />## set the default batch size for batch fetching</p> <p>#hibernate.default_batch_fetch_size 8</p> <p><br />## rollback generated identifier values of deleted entities to default values</p> <p>#hibernate.use_identifer_rollback true</p> <p><br />## enable bytecode reflection optimizer (disabled by default)</p> <p>#hibernate.bytecode.use_reflection_optimizer true</p> <p><br />#####################<br />### JDBC Settings ###<br />#####################</p> <p>## specify a JDBC isolation level</p> <p>#hibernate.connection.isolation 4</p> <p><br />## enable JDBC autocommit (not recommended!)</p> <p>#hibernate.connection.autocommit true</p> <p><br />## set the JDBC fetch size</p> <p>#hibernate.jdbc.fetch_size 25</p> <p><br />## set the maximum JDBC 2 batch size (a nonzero value enables batching)</p> <p>#hibernate.jdbc.batch_size 5<br />#hibernate.jdbc.batch_size 0</p> <p><br />## enable batch updates even for versioned data</p> <p>hibernate.jdbc.batch_versioned_data true</p> <p><br />## enable use of JDBC 2 scrollable ResultSets (specifying a Dialect will cause Hibernate to use a sensible default)</p> <p>#hibernate.jdbc.use_scrollable_resultset true</p> <p><br />## use streams when writing binary types to / from JDBC</p> <p>hibernate.jdbc.use_streams_for_binary true</p> <p><br />## use JDBC 3 PreparedStatement.getGeneratedKeys() to get the identifier of an inserted row</p> <p>#hibernate.jdbc.use_get_generated_keys false</p> <p><br />## choose a custom JDBC batcher</p> <p># hibernate.jdbc.factory_class</p> <p><br />## enable JDBC result set column alias caching <br />## (minor performance enhancement for broken JDBC drivers)</p> <p># hibernate.jdbc.wrap_result_sets</p> <p><br />## choose a custom SQL exception converter</p> <p>#hibernate.jdbc.sql_exception_converter</p> <p><br />##########################<br />### Second-level Cache ###<br />##########################</p> <p>## optimize chache for minimal "puts" instead of minimal "gets" (good for clustered cache)</p> <p>#hibernate.cache.use_minimal_puts true</p> <p><br />## set a prefix for cache region names</p> <p>hibernate.cache.region_prefix hibernate.test</p> <p><br />## disable the second-level cache</p> <p>#hibernate.cache.use_second_level_cache false</p> <p><br />## enable the query cache</p> <p>#hibernate.cache.use_query_cache true</p> <p><br />## store the second-level cache entries in a more human-friendly format</p> <p>#hibernate.cache.use_structured_entries true</p> <p><br />## choose a cache implementation</p> <p>#hibernate.cache.provider_class org.hibernate.cache.EhCacheProvider<br />#hibernate.cache.provider_class org.hibernate.cache.EmptyCacheProvider<br />hibernate.cache.provider_class org.hibernate.cache.HashtableCacheProvider<br />#hibernate.cache.provider_class org.hibernate.cache.TreeCacheProvider<br />#hibernate.cache.provider_class org.hibernate.cache.OSCacheProvider<br />#hibernate.cache.provider_class org.hibernate.cache.SwarmCacheProvider</p> <p><br />## choose a custom query cache implementation</p> <p>#hibernate.cache.query_cache_factory</p> <p><br />############<br />### JNDI ###<br />############</p> <p>## specify a JNDI name for the SessionFactory</p> <p>#hibernate.session_factory_name hibernate/session_factory</p> <p><br />## Hibernate uses JNDI to bind a name to a SessionFactory and to look up the JTA UserTransaction;<br />## if hibernate.jndi.* are not specified, Hibernate will use the default InitialContext() which<br />## is the best approach in an application server</p> <p>#file system<br />#hibernate.jndi.class com.sun.jndi.fscontext.RefFSContextFactory<br />#hibernate.jndi.url file:/</p> <p>#WebSphere<br />#hibernate.jndi.class com.ibm.websphere.naming.WsnInitialContextFactory<br />#hibernate.jndi.url iiop://localhost:900/</p></div><img src ="http://www.blogjava.net/xiaohuzi2008/aggbug/402770.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaohuzi2008/" target="_blank">小胡子</a> 2013-08-14 09:29 <a href="http://www.blogjava.net/xiaohuzi2008/archive/2013/08/14/402770.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>