码迷,mamicode.com
首页 > 数据库 > 详细

各数据库连接配置与maven依赖安装

时间:2016-07-06 14:38:31      阅读:342      评论:0      收藏:0      [点我收藏+]

标签:

  maven用的比较多,所以自己去捣鼓了一下:以下是关于数据库配置的一块,把相关的内容张贴出来,以备不时之需

  //MySql

  配置文件(maven)

  <dependency>

    <groupId>mysql</groupId>

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

    <version>5.0.5</version>

  </dependency>

  配置文件:(hibernat.properties)

    hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect

    hibernate.connection.driver_calss=mysql.jdbc.Driver

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

    hibernate.connection.username=root

    hibernate.connection.password=****

    hibernate.connection.hbm2ddl.auto=update

  //Oracle

  配置文件(maven)

  <dependency>

    <groupId>com.oracle</groupId>

    <artifactId>ojdbc14</artifactId>

    <version>10.2.0.2.1</version>

  </dependency>

  配置文件:(hibernat.properties)

    hibernate.dialect=org.hibernate.dialect.Oracle9Dialect

    hibernate.connection.driver_calss=oracle.jdbc.OracleDriver

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

    hibernate.connection.username=system

    hibernate.connection.password=****

    hibernate.connection.hbm2ddl.auto=update

  //SQL Server

  配置文件(maven)

  <dependency>

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

    <artifactId>jtds</artifactId>

    <version>1.2</version>

  </dependency>

  配置文件:(hibernat.properties)

    hibernate.dialect=org.hibernate.dialect.SQLServerDialect

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

     hibernate.connection.url=jdbc:jtds:sqlserver://localhost:1433/trails?createDatabaseIfNotExist=true&ampo;useUnicode=ture&amp;characterEncoding=utf-8

    hibernate.connection.username=sa

    hibernate.connection.password=****

    hibernate.connection.hbm2ddl.auto=update

  //手动安装maven依赖包

  1:将此依赖添加到项目的pom.xml

  <dependency>

    <groupId>com.microsoft.sqlserver</groupId>

    <artifactId>sqljdbc4</artifactId>

    <version>3.0</version>

  </dependency>

  2:在命令行中执行install命令

  mvn install:install-file -Dfile=sqljdbc4-3.0.jar -

  DgroupId=com.microsoft.sqlserver -

  DartifactId=sqljdbc4-Dversion=3.0 -

  Dpackaging=jar

  3:将sqljdbc4-3.0.jar拷贝到此依赖安装目录

  将sqljdbc4-3.0.jar拷贝到\Documents and Settings\%USER%\.m2\repository\com\microsoft\sqlserver\sqljdbc\4\3.0中即可

  来源网络。

各数据库连接配置与maven依赖安装

标签:

原文地址:http://www.cnblogs.com/lpwbk/p/5646624.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!