Java各資料庫jdbc連線,和需要的jar包

o0心境0o發表於2014-12-25

共同依賴spring-jdbc:

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>

PostgreSql連線:

jdbc.driverClassName=org.postgresql.Driver

jdbc.url=jdbc:postgresql://localhost:5432/test_db?useUnicode=true&characterEncoding=utf-8


<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>


Mysql連線:

jdbc.driverClassName=com.mysql.jdbc.Driver 

jdbc.url=jdbc:mysql://localhost:3306/test_db?useUnicode=true&characterEncoding=utf-8

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.18</version>
</dependency>


Oracle連線:

jdbc.driverClassName=oracle.jdbc.driver.OracleDriver 

jdbc.url=jdbc:oracle:thin:@localhost:1521:test_db?useUnicode=true&characterEncoding=utf-8

<dependency>

        <groupId>com.oracle</groupId>

        <artifactId>ojdbc14</artifactId> 

        <version>10.2.0.1.0</version>

 </dependency> 


SqlServer連線:

jdbc.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver

jdbc.url=jdbc:sqlserver://localhost:1433; DatabaseName=test_db?useUnicode=true&characterEncoding=utf-8

<dependency>
   <groupId>com.microsoft.sqlserver</groupId>
   <artifactId>sqljdbc4</artifactId>
   <version>3.0</version>
</dependency>

嵌入式資料庫H2(用於測試):

jdbc.driverClassName=org.h2.Driver

jdbc.url=jdbc:h2:mem:test_db;DB_CLOSE_DELAY=-1;MODE=Mysql;TRACE_LEVEL_SYSTEM_OUT=2

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.184</version>
</dependency>




相關文章