首页 > 数据库 >各数据库连接maven配置 各种数据库Hibernate链接配置

各数据库连接maven配置 各种数据库Hibernate链接配置

时间:2023-06-13 14:01:36浏览次数:35  
标签:Hibernate version 数据库 driver maven dependency connection hibernate artifactId


评:

Derby

db driver maven dependency

<           dependency           >          


                      <           groupId           >org.apache.derby</           groupId           >          


                      <           artifactId           >derbyclient</           artifactId           >          


                      <           version           >10.2.2.0</           version           >          


           </           dependency           >


hibernate.properties

hibernate.dialect=org.hibernate.dialect.DerbyDialect          


           hibernate.connection.driver_class=org.apache.derby.jdbc.ClientDriver          


           hibernate.connection.url=jdbc:derby:           //localhost/trails;create=true          


           hibernate.connection.username=any          


           hibernate.connection.password=value          


           hibernate.hbm2ddl.auto=update



 MySQL



MySQL throws an EOFException when the database connection has been closed after the lease has expired, but it works again on subsequent requests.
There is a reported issue with DBCP and the MySQL driver. Check the JIRA issue for more info and a possible solutionhttp://jira.codehaus.org/browse/TRAILS-85



db driver maven dependency



<           dependency           >          


                      <           groupId           >mysql</           groupId           >          


                      <           artifactId           >mysql-connector-java</           artifactId           >          


                      <           version           >5.0.5</           version           >          


           </           dependency           >



hibernate.properties



hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect          


           hibernate.connection.driver_class=com.mysql.jdbc.Driver          


           hibernate.connection.url=jdbc:mysql:           //localhost/trails?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8          


           hibernate.connection.username=root          


           hibernate.connection.password=          


           hibernate.hbm2ddl.auto=update



H2



db driver maven dependency



<           dependency           >          


                      <           groupId           >com.h2database</           groupId           >          


                      <           artifactId           >h2</           artifactId           >          


                      <           version           >1.0.20070304</           version           >          


           </           dependency           >



hibernate.dialect=org.hibernate.dialect.H2Dialect          


           hibernate.connection.driver_class=org.h2.Driver          


           hibernate.connection.url=jdbc:h2:trails          


           hibernate.connection.username=sa          


           hibernate.connection.password=          


           hibernate.hbm2ddl.auto=update



Oracle 



db driver maven dependency



<           dependency           >          


                      <           groupId           >com.oracle</           groupId           >          


                      <           artifactId           >ojdbc14</           artifactId           >          


                      <           version           >10.2.0.2.0</           version           >          


           </           dependency           >



hibernate.properties



hibernate.dialect=org.hibernate.dialect.Oracle9Dialect          


           hibernate.connection.driver_class=oracle.jdbc.OracleDriver          


           hibernate.connection.url=jdbc:oracle:thin:           @localhost           :           1521           :XE          


           hibernate.connection.username=system          


           hibernate.connection.password=system          


           hibernate.hbm2ddl.auto=update          


                      


           # The Oracle JDBC driver doesn't like prepared statement caching very much.          


           hibernate.statement_cache.size=           0          


           # or baching with BLOBs very much.          


           hibernate.jdbc.batch_size=           0          


                      


           # After a            while           , Oracle            throws           this           exception: too many open cursors          


           # Disable PreparedStatement caching            for           the connection pool too.          


           # http:           //www.hibernate.org/120.html#A10          


           hibernate.dbcp.ps.maxIdle =            0          


                      


           # Stoping hibernate from using the column-names in queries to retrieve data from the resultsets          


           # More info in http:           //www.jroller.com/page/dashorst?entry=hibernate_3_1_something_performance1          


           hibernate.jdbc.wrap_result_sets=           true



PostgreSQL.



db driver maven dependency



<           dependency           >          


                      <           groupId           >postgresql</           groupId           >          


                      <           artifactId           >postgresql</           artifactId           >          


                      <           version           >8.2-504.jdbc3</           version           >          


           </           dependency           >



hibernate.properties



hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect          


           hibernate.connection.driver_class=org.postgresql.Driver          


           hibernate.connection.url=jdbc:postgresql:           //localhost/trails          


           hibernate.connection.username=postgres          


           hibernate.connection.password=postgres          


           hibernate.hbm2ddl.auto=update



Microsoft SQL Server

db driver maven dependency



<           dependency           >          


                      <           groupId           >net.sourceforge.jtds</           groupId           >          


                      <           artifactId           >jtds</           artifactId           >          


                      <           version           >1.2</           version           >          


           </           dependency           >

hibernate.properties

hibernate.dialect=org.hibernate.dialect.SQLServerDialect          


           hibernate.connection.driver_class=net.sourceforge.jtds.jdbc.Driver          


           hibernate.connection.url=jdbc:jtds:sqlserver:           //localhost:1433/trails          


           hibernate.connection.username=sa          


           hibernate.connection.password=          


           hibernate.hbm2ddl.auto=update



HSQLDB 

db driver maven dependency

<           dependency           >          


                      <           groupId           >hsqldb</           groupId           >          


                      <           artifactId           >hsqldb</           artifactId           >          


                      <           version           >1.8.0.7</           version           >          


           </           dependency           >

hibernate.properties

hibernate.dialect=org.hibernate.dialect.HSQLDialect 
  
 
  
 
   hibernate.connection.driver_class=org.hsqldb.jdbcDriver 
  
 
  
 
   hibernate.connection.url=jdbc:hsqldb:trails;shutdown= 
   true 
  
 
  
 
   hibernate.connection.username=sa 
  
 
  
 
   hibernate.connection.password= 
  
 
  
 
   hibernate.hbm2ddl.auto=update

标签:Hibernate,version,数据库,driver,maven,dependency,connection,hibernate,artifactId
From: https://blog.51cto.com/u_16080829/6469305

相关文章

  • Eclipse环境搭建全集(个人使用的环境,Eclipse+SVN+Maven+JbossTo...
    评:1.JDK的配置去官网下载JDK,需要注意的是JDK32位,Eclipse也必须是32位.64位JDK对应Eclipse64位.1.安装JDK,安装过程中最好自定义安装目录等信息,如我们选择安装目录为E:\software\Java\jdk1.6.0_34.2.安装完成后,我的电脑点击属性,选择高级选项卡点击环境变量.3.在系统变量......
  • Maven依赖中的scope总结
    scope是限制Dependency的作用范围的,影响maven项目在各个生命周期时导入的package的状态。自2.0.9版本发布后,新增了一种:import,现在已经有了6种scope。下面分别来说明:compile:不声明scope元素的情况下的默认值。compile表示被依赖包需要参与当前项目的编译,包括后续的测试,运行周......
  • 014 数据库学习笔记--查询
    常用查询方式:select*fromtablenameselectcol1,clo2fromtablenamewhereage=18selectcol1,clo2fromtablenamewhere age>=18andage<=60selectcol1,clo2fromtablenamewhere agebetween18and60selecttop(100)col1,clo2fromtablenamewhere ......
  • 一文解读.NET 数据库事务
    事务是数据库系统中的重要概念,本文讲解作者从业CRUD十余载的事务多种使用方式总结。以下所有内容都是针对单机事务而言,不涉及分布式事务相关的东西!关于事务原理的讲解不针对具体的某个数据库实现,所以某些地方可能和你的实践经验不符。1|0认识事务为什么需要数据库事务?转账是生......
  • s1sh整合实例 Strut1.2+Spring2.6+Hibernate3.2
    [code]开发环境:MyEclipse8.5+Mysql说明:本实例是简单注册程序(只有两个属性)数据库脚本:user.sqlCREATETABLE`user`(`Id`int(11)NOTNULLAUTO_INCREMENT,`username`varchar(255)DEFAULTNULL,`password`varchar(255)DEFAULTNULL,P......
  • Hibernate基础
    Hibernate基础[code]Part11.持久化对象Eventevent=newEvent();//populatetheeventSessionsession=factory.openSession();session.save(event);session.flush();session.close();当保存一个对象的时候,hibernate出于性能......
  • SQL 2012 更换数据库路径
    SQL2012更换数据库路径 SQL2012更换数据库路径Sqlserver数据库存储路径的修改Sqlserver数据库存储路径问题:本系统sqlserver路径默认是存储在C盘目录下的,由于数据会慢慢变大和避免重装系统数据丢失等问题,最好手动将路径设置在D盘。更改路径方法:情况一:更改数据库默认存储路......
  • Hibernate数据校验简介
    Hibernate数据校验简介我们在业务中经常会遇到参数校验问题,比如前端参数校验、Kafka消息参数校验等,如果业务逻辑比较复杂,各种实体比较多的时候,我们通过代码对这些数据一一校验,会出现大量的重复代码以及和主要业务无关的逻辑。SpringMVC提供了参数校验机制,但是其底层还是通过Hib......
  • 2023.6.12 03.数据库基本操作
    1.数据库连接⽅式2.SQL语⾔3.Mysql数据库对应与应⽤4.数据库基本操作5.数据库增删查改6.数据库查询语句6.1单表查询6.2多表查询6.3⼦查询 系统数据库information_schema(虚拟库)⽤户表信息、列信息、权限信息、字符信息等#查询有多少个库mysql>SELECTCOUNT(*)......
  • centos7 虚拟机安装 MySQL数据库
    检查是否安装过MySQL以及版本信息rpm-qa|grep-imysql卸载之前的版本,参数-e表示删除,-nodeps表示不校验依赖关系rpm-emysql-5.1.47-4.el6.x86_64–nodeps二进制包格式安装的mysql卸载如果我们的mysql是通过二级制包格式安装的,则rpm-qa|grep-imysql是......