各數據庫連接配置與maven依賴安裝


  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中即可

  來源網絡。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM