打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Hibernate配置文件中配置各种数据库的driver、URL
Java代码  
  1. hibernate.properties  
  2.   
  3. ######################  
  4. ### Query Language ###  
  5. ######################  
  6.   
  7. ## define query language constants / function names  
  8.   
  9. hibernate.query.substitutions yes 'Y', no 'N'  
  10.   
  11.   
  12. ## select the classic query parser  
  13.   
  14. #hibernate.query.factory_class org.hibernate.hql.classic.ClassicQueryTranslatorFactory  
  15.   
  16.   
  17. #################  
  18. ### Platforms ###  
  19. #################  
  20.   
  21. ## JNDI Datasource  
  22.   
  23. #hibernate.connection.datasource jdbc/test  
  24. #hibernate.connection.username db2  
  25. #hibernate.connection.password db2  
  26.   
  27.   
  28. ## HypersonicSQL  
  29.   
  30. hibernate.dialect org.hibernate.dialect.HSQLDialect  
  31. hibernate.connection.driver_class org.hsqldb.jdbcDriver  
  32. hibernate.connection.username sa  
  33. hibernate.connection.password  
  34. hibernate.connection.url jdbc:hsqldb:./build/db/hsqldb/hibernate  
  35. #hibernate.connection.url jdbc:hsqldb:hsql://localhost  
  36. #hibernate.connection.url jdbc:hsqldb:test  
  37.   
  38. ## H2 (www.h2database.com)  
  39. #hibernate.dialect org.hibernate.dialect.H2Dialect  
  40. #hibernate.connection.driver_class org.h2.Driver  
  41. #hibernate.connection.username sa  
  42. #hibernate.connection.password  
  43. #hibernate.connection.url jdbc:h2:mem:./build/db/h2/hibernate  
  44. #hibernate.connection.url jdbc:h2:testdb/h2test  
  45. #hibernate.connection.url jdbc:h2:mem:imdb1  
  46. #hibernate.connection.url jdbc:h2:tcp://dbserv:8084/sample;   
  47. #hibernate.connection.url jdbc:h2:ssl://secureserv:8085/sample;   
  48. #hibernate.connection.url jdbc:h2:ssl://secureserv/testdb;cipher=AES  
  49.   
  50. ## MySQL  
  51.   
  52. #hibernate.dialect org.hibernate.dialect.MySQLDialect  
  53. #hibernate.dialect org.hibernate.dialect.MySQLInnoDBDialect  
  54. #hibernate.dialect org.hibernate.dialect.MySQLMyISAMDialect  
  55. #hibernate.connection.driver_class com.mysql.jdbc.Driver  
  56. #hibernate.connection.url jdbc:mysql:///test  
  57. #hibernate.connection.username gavin  
  58. #hibernate.connection.password  
  59.   
  60.   
  61. ## Oracle  
  62.   
  63. #hibernate.dialect org.hibernate.dialect.OracleDialect  
  64. #hibernate.dialect org.hibernate.dialect.Oracle9Dialect  
  65. #hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver  
  66. #hibernate.connection.username ora  
  67. #hibernate.connection.password ora  
  68. #hibernate.connection.url jdbc:oracle:thin:@localhost:1521:orcl  
  69. #hibernate.connection.url jdbc:oracle:thin:@localhost:1522:XE  
  70.   
  71.   
  72. ## PostgreSQL  
  73.   
  74. #hibernate.dialect org.hibernate.dialect.PostgreSQLDialect  
  75. #hibernate.connection.driver_class org.postgresql.Driver  
  76. #hibernate.connection.url jdbc:postgresql:template1  
  77. #hibernate.connection.username pg  
  78. #hibernate.connection.password  
  79.   
  80.   
  81. ## DB2  
  82.   
  83. #hibernate.dialect org.hibernate.dialect.DB2Dialect  
  84. #hibernate.connection.driver_class com.ibm.db2.jcc.DB2Driver  
  85. #hibernate.connection.driver_class COM.ibm.db2.jdbc.app.DB2Driver  
  86. #hibernate.connection.url jdbc:db2://localhost:50000/somename  
  87. #hibernate.connection.url jdbc:db2:somename  
  88. #hibernate.connection.username db2  
  89. #hibernate.connection.password db2  
  90.   
  91. ## TimesTen  
  92.   
  93. #hibernate.dialect org.hibernate.dialect.TimesTenDialect  
  94. #hibernate.connection.driver_class com.timesten.jdbc.TimesTenDriver  
  95. #hibernate.connection.url jdbc:timesten:direct:test  
  96. #hibernate.connection.username  
  97. #hibernate.connection.password  
  98.   
  99. ## DB2/400  
  100.   
  101. #hibernate.dialect org.hibernate.dialect.DB2400Dialect  
  102. #hibernate.connection.username user  
  103. #hibernate.connection.password password  
  104.   
  105. ## Native driver  
  106. #hibernate.connection.driver_class COM.ibm.db2.jdbc.app.DB2Driver  
  107. #hibernate.connection.url jdbc:db2://systemname  
  108.   
  109. ## Toolbox driver  
  110. #hibernate.connection.driver_class com.ibm.as400.access.AS400JDBCDriver  
  111. #hibernate.connection.url jdbc:as400://systemname  
  112.   
  113.   
  114. ## Derby (not supported!)  
  115.   
  116. #hibernate.dialect org.hibernate.dialect.DerbyDialect  
  117. #hibernate.connection.driver_class org.apache.derby.jdbc.EmbeddedDriver  
  118. #hibernate.connection.username  
  119. #hibernate.connection.password  
  120. #hibernate.connection.url jdbc:derby:build/db/derby/hibernate;create=true  
  121.   
  122.   
  123. ## Sybase  
  124.   
  125. #hibernate.dialect org.hibernate.dialect.SybaseDialect  
  126. #hibernate.connection.driver_class com.sybase.jdbc2.jdbc.SybDriver  
  127. #hibernate.connection.username sa  
  128. #hibernate.connection.password sasasa  
  129. #hibernate.connection.url jdbc:sybase:Tds:co3061835-a:5000/tempdb  
  130.   
  131.   
  132. ## Mckoi SQL  
  133.   
  134. #hibernate.dialect org.hibernate.dialect.MckoiDialect  
  135. #hibernate.connection.driver_class com.mckoi.JDBCDriver  
  136. #hibernate.connection.url jdbc:mckoi:///  
  137. #hibernate.connection.url jdbc:mckoi:local://C:/mckoi1.0.3/db.conf  
  138. #hibernate.connection.username admin  
  139. #hibernate.connection.password nimda  
  140.   
  141.   
  142. ## SAP DB  
  143.   
  144. #hibernate.dialect org.hibernate.dialect.SAPDBDialect  
  145. #hibernate.connection.driver_class com.sap.dbtech.jdbc.DriverSapDB  
  146. #hibernate.connection.url jdbc:sapdb://localhost/TST  
  147. #hibernate.connection.username TEST  
  148. #hibernate.connection.password TEST  
  149. #hibernate.query.substitutions yes 'Y', no 'N'  
  150.   
  151.   
  152. ## MS SQL Server  
  153.   
  154. #hibernate.dialect org.hibernate.dialect.SQLServerDialect  
  155. #hibernate.connection.username sa  
  156. #hibernate.connection.password sa  
  157.   
  158. ## JSQL Driver  
  159. #hibernate.connection.driver_class com.jnetdirect.jsql.JSQLDriver  
  160. #hibernate.connection.url jdbc:JSQLConnect://1E1/test  
  161.   
  162. ## JTURBO Driver  
  163. #hibernate.connection.driver_class com.newatlanta.jturbo.driver.Driver  
  164. #hibernate.connection.url jdbc:JTurbo://1E1:1433/test  
  165.   
  166. ## WebLogic Driver  
  167. #hibernate.connection.driver_class weblogic.jdbc.mssqlserver4.Driver  
  168. #hibernate.connection.url jdbc:weblogic:mssqlserver4:1E1:1433  
  169.   
  170. ## Microsoft Driver (not recommended!)  
  171. #hibernate.connection.driver_class com.microsoft.jdbc.sqlserver.SQLServerDriver  
  172. #hibernate.connection.url jdbc:microsoft:sqlserver://1E1;DatabaseName=test;SelectMethod=cursor  
  173.   
  174. ## The New Microsoft Driver   
  175. #hibernate.connection.driver_class com.microsoft.sqlserver.jdbc.SQLServerDriver  
  176. #hibernate.connection.url jdbc:sqlserver://localhost  
  177.   
  178. ## jTDS (since version 0.9)  
  179. #hibernate.connection.driver_class net.sourceforge.jtds.jdbc.Driver  
  180. #hibernate.connection.url jdbc:jtds:sqlserver://1E1/test  
  181.   
  182. ## Interbase  
  183.   
  184. #hibernate.dialect org.hibernate.dialect.InterbaseDialect  
  185. #hibernate.connection.username sysdba  
  186. #hibernate.connection.password masterkey  
  187.   
  188. ## DO NOT specify hibernate.connection.sqlDialect  
  189.   
  190. ## InterClient  
  191.   
  192. #hibernate.connection.driver_class interbase.interclient.Driver  
  193. #hibernate.connection.url jdbc:interbase://localhost:3060/C:/firebird/test.gdb  
  194.   
  195. ## Pure Java  
  196.   
  197. #hibernate.connection.driver_class org.firebirdsql.jdbc.FBDriver  
  198. #hibernate.connection.url jdbc:firebirdsql:localhost/3050:/firebird/test.gdb  
  199.   
  200.   
  201. ## Pointbase  
  202.   
  203. #hibernate.dialect org.hibernate.dialect.PointbaseDialect  
  204. #hibernate.connection.driver_class com.pointbase.jdbc.jdbcUniversalDriver  
  205. #hibernate.connection.url jdbc:pointbase:embedded:sample  
  206. #hibernate.connection.username PBPUBLIC  
  207. #hibernate.connection.password PBPUBLIC  
  208.   
  209.   
  210. ## Ingres  
  211.   
  212. ## older versions (before Ingress 2006)  
  213.   
  214. #hibernate.dialect org.hibernate.dialect.IngresDialect  
  215. #hibernate.connection.driver_class ca.edbc.jdbc.EdbcDriver  
  216. #hibernate.connection.url jdbc:edbc://localhost:II7/database  
  217. #hibernate.connection.username user  
  218. #hibernate.connection.password password  
  219.   
  220. ## Ingres 2006 or later  
  221.   
  222. #hibernate.dialect org.hibernate.dialect.IngresDialect  
  223. #hibernate.connection.driver_class com.ingres.jdbc.IngresDriver  
  224. #hibernate.connection.url jdbc:ingres://localhost:II7/database;CURSOR=READONLY;auto=multi  
  225. #hibernate.connection.username user  
  226. #hibernate.connection.password password  
  227.   
  228. ## Mimer SQL  
  229.   
  230. #hibernate.dialect org.hibernate.dialect.MimerSQLDialect  
  231. #hibernate.connection.driver_class com.mimer.jdbc.Driver  
  232. #hibernate.connection.url jdbc:mimer:multi1  
  233. #hibernate.connection.username hibernate  
  234. #hibernate.connection.password hibernate  
  235.   
  236.   
  237. ## InterSystems Cache  
  238.   
  239. #hibernate.dialect org.hibernate.dialect.Cache71Dialect  
  240. #hibernate.connection.driver_class com.intersys.jdbc.CacheDriver  
  241. #hibernate.connection.username _SYSTEM  
  242. #hibernate.connection.password SYS  
  243. #hibernate.connection.url jdbc:Cache://127.0.0.1:1972/HIBERNATE  
  244.   
  245.   
  246. #################################  
  247. ### Hibernate Connection Pool ###  
  248. #################################  
  249.   
  250. hibernate.connection.pool_size 1  
  251.   
  252.   
  253. ###########################  
  254. ### C3P0 Connection Pool###  
  255. ###########################  
  256.   
  257. #hibernate.c3p0.max_size 2  
  258. #hibernate.c3p0.min_size 2  
  259. #hibernate.c3p0.timeout 5000  
  260. #hibernate.c3p0.max_statements 100  
  261. #hibernate.c3p0.idle_test_period 3000  
  262. #hibernate.c3p0.acquire_increment 2  
  263. #hibernate.c3p0.validate false  
  264.   
  265.   
  266. ##############################  
  267. ### Proxool Connection Pool###  
  268. ##############################  
  269.   
  270. ## Properties for external configuration of Proxool  
  271.   
  272. hibernate.proxool.pool_alias pool1  
  273.   
  274. ## Only need one of the following  
  275.   
  276. #hibernate.proxool.existing_pool true  
  277. #hibernate.proxool.xml proxool.xml  
  278. #hibernate.proxool.properties proxool.properties  
  279.   
  280.   
  281. #################################  
  282. ### Plugin ConnectionProvider ###  
  283. #################################  
  284.   
  285. ## use a custom ConnectionProvider (if not set, Hibernate will choose a built-in ConnectionProvider using hueristics)  
  286.   
  287. #hibernate.connection.provider_class org.hibernate.connection.DriverManagerConnectionProvider  
  288. #hibernate.connection.provider_class org.hibernate.connection.DatasourceConnectionProvider  
  289. #hibernate.connection.provider_class org.hibernate.connection.C3P0ConnectionProvider  
  290. #hibernate.connection.provider_class org.hibernate.connection.ProxoolConnectionProvider  
  291.   
  292.   
  293. #######################  
  294. ### Transaction API ###  
  295. #######################  
  296.   
  297. ## Enable automatic flush during the JTA beforeCompletion() callback  
  298. ## (This setting is relevant with or without the Transaction API)  
  299.   
  300. #hibernate.transaction.flush_before_completion  
  301.   
  302.   
  303. ## Enable automatic session close at the end of transaction  
  304. ## (This setting is relevant with or without the Transaction API)  
  305.   
  306. #hibernate.transaction.auto_close_session  
  307.   
  308.   
  309. ## the Transaction API abstracts application code from the underlying JTA or JDBC transactions  
  310.   
  311. #hibernate.transaction.factory_class org.hibernate.transaction.JTATransactionFactory  
  312. #hibernate.transaction.factory_class org.hibernate.transaction.JDBCTransactionFactory  
  313.   
  314.   
  315. ## to use JTATransactionFactory, Hibernate must be able to locate the UserTransaction in JNDI  
  316. ## default is java:comp/UserTransaction  
  317. ## you do NOT need this setting if you specify hibernate.transaction.manager_lookup_class  
  318.   
  319. #jta.UserTransaction jta/usertransaction  
  320. #jta.UserTransaction javax.transaction.UserTransaction  
  321. #jta.UserTransaction UserTransaction  
  322.   
  323.   
  324. ## to use the second-level cache with JTA, Hibernate must be able to obtain the JTA TransactionManager  
  325.   
  326. #hibernate.transaction.manager_lookup_class org.hibernate.transaction.JBossTransactionManagerLookup  
  327. #hibernate.transaction.manager_lookup_class org.hibernate.transaction.WeblogicTransactionManagerLookup  
  328. #hibernate.transaction.manager_lookup_class org.hibernate.transaction.WebSphereTransactionManagerLookup  
  329. #hibernate.transaction.manager_lookup_class org.hibernate.transaction.OrionTransactionManagerLookup  
  330. #hibernate.transaction.manager_lookup_class org.hibernate.transaction.ResinTransactionManagerLookup  
  331.   
  332.   
  333. ##############################  
  334. ### Miscellaneous Settings ###  
  335. ##############################  
  336.   
  337. ## print all generated SQL to the console  
  338.   
  339. #hibernate.show_sql true  
  340.   
  341.   
  342. ## format SQL in log and console  
  343.   
  344. hibernate.format_sql true  
  345.   
  346.   
  347. ## add comments to the generated SQL  
  348.   
  349. #hibernate.use_sql_comments true  
  350.   
  351.   
  352. ## generate statistics  
  353.   
  354. #hibernate.generate_statistics true  
  355.   
  356.   
  357. ## auto schema export  
  358.   
  359. #hibernate.hbm2ddl.auto create-drop  
  360. #hibernate.hbm2ddl.auto create  
  361. #hibernate.hbm2ddl.auto update  
  362. #hibernate.hbm2ddl.auto validate  
  363.   
  364.   
  365. ## specify a default schema and catalog for unqualified tablenames  
  366.   
  367. #hibernate.default_schema test  
  368. #hibernate.default_catalog test  
  369.   
  370.   
  371. ## enable ordering of SQL UPDATEs by primary key  
  372.   
  373. #hibernate.order_updates true  
  374.   
  375.   
  376. ## set the maximum depth of the outer join fetch tree  
  377.   
  378. hibernate.max_fetch_depth 1  
  379.   
  380.   
  381. ## set the default batch size for batch fetching  
  382.   
  383. #hibernate.default_batch_fetch_size 8  
  384.   
  385.   
  386. ## rollback generated identifier values of deleted entities to default values  
  387.   
  388. #hibernate.use_identifer_rollback true  
  389.   
  390.   
  391. ## enable bytecode reflection optimizer (disabled by default)  
  392.   
  393. #hibernate.bytecode.use_reflection_optimizer true  
  394.   
  395.   
  396. #####################  
  397. ### JDBC Settings ###  
  398. #####################  
  399.   
  400. ## specify a JDBC isolation level  
  401.   
  402. #hibernate.connection.isolation 4  
  403.   
  404.   
  405. ## enable JDBC autocommit (not recommended!)  
  406.   
  407. #hibernate.connection.autocommit true  
  408.   
  409.   
  410. ## set the JDBC fetch size  
  411.   
  412. #hibernate.jdbc.fetch_size 25  
  413.   
  414.   
  415. ## set the maximum JDBC 2 batch size (a nonzero value enables batching)  
  416.   
  417. #hibernate.jdbc.batch_size 5  
  418. #hibernate.jdbc.batch_size 0  
  419.   
  420.   
  421. ## enable batch updates even for versioned data  
  422.   
  423. hibernate.jdbc.batch_versioned_data true  
  424.   
  425.   
  426. ## enable use of JDBC 2 scrollable ResultSets (specifying a Dialect will cause Hibernate to use a sensible default)  
  427.   
  428. #hibernate.jdbc.use_scrollable_resultset true  
  429.   
  430.   
  431. ## use streams when writing binary types to / from JDBC  
  432.   
  433. hibernate.jdbc.use_streams_for_binary true  
  434.   
  435.   
  436. ## use JDBC 3 PreparedStatement.getGeneratedKeys() to get the identifier of an inserted row  
  437.   
  438. #hibernate.jdbc.use_get_generated_keys false  
  439.   
  440.   
  441. ## choose a custom JDBC batcher  
  442.   
  443. # hibernate.jdbc.factory_class  
  444.   
  445.   
  446. ## enable JDBC result set column alias caching   
  447. ## (minor performance enhancement for broken JDBC drivers)  
  448.   
  449. # hibernate.jdbc.wrap_result_sets  
  450.   
  451.   
  452. ## choose a custom SQL exception converter  
  453.   
  454. #hibernate.jdbc.sql_exception_converter  
  455.   
  456.   
  457. ##########################  
  458. ### Second-level Cache ###  
  459. ##########################  
  460.   
  461. ## optimize chache for minimal "puts" instead of minimal "gets" (good for clustered cache)  
  462.   
  463. #hibernate.cache.use_minimal_puts true  
  464.   
  465.   
  466. ## set a prefix for cache region names  
  467.   
  468. hibernate.cache.region_prefix hibernate.test  
  469.   
  470.   
  471. ## disable the second-level cache  
  472.   
  473. #hibernate.cache.use_second_level_cache false  
  474.   
  475.   
  476. ## enable the query cache  
  477.   
  478. #hibernate.cache.use_query_cache true  
  479.   
  480.   
  481. ## store the second-level cache entries in a more human-friendly format  
  482.   
  483. #hibernate.cache.use_structured_entries true  
  484.   
  485.   
  486. ## choose a cache implementation  
  487.   
  488. #hibernate.cache.provider_class org.hibernate.cache.EhCacheProvider  
  489. #hibernate.cache.provider_class org.hibernate.cache.EmptyCacheProvider  
  490. hibernate.cache.provider_class org.hibernate.cache.HashtableCacheProvider  
  491. #hibernate.cache.provider_class org.hibernate.cache.TreeCacheProvider  
  492. #hibernate.cache.provider_class org.hibernate.cache.OSCacheProvider  
  493. #hibernate.cache.provider_class org.hibernate.cache.SwarmCacheProvider  
  494.   
  495.   
  496. ## choose a custom query cache implementation  
  497.   
  498. #hibernate.cache.query_cache_factory  
  499.   
  500.   
  501. ############  
  502. ### JNDI ###  
  503. ############  
  504.   
  505. ## specify a JNDI name for the SessionFactory  
  506.   
  507. #hibernate.session_factory_name hibernate/session_factory  
  508.   
  509.   
  510. ## Hibernate uses JNDI to bind a name to a SessionFactory and to look up the JTA UserTransaction;  
  511. ## if hibernate.jndi.* are not specified, Hibernate will use the default InitialContext() which  
  512. ## is the best approach in an application server  
  513.   
  514. #file system  
  515. #hibernate.jndi.class com.sun.jndi.fscontext.RefFSContextFactory  
  516. #hibernate.jndi.url file:/  
  517.   
  518. #WebSphere  
  519. #hibernate.jndi.class com.ibm.websphere.naming.WsnInitialContextFactory  
  520. #hibernate.jndi.url iiop://localhost:900/  
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Hibernate 不同数据库的连接及SQL方言
config.properties
提供JDBC連接
单机数据库性能测试总结
Hibernate连接池配置
JBPM工作流引擎使用环境的搭建
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服