各种数据库maven依赖的安装与bernate链接配置
各种数据库Hibernate链接配置
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.DerbyDialecthibernate.connection.driver_class=org.apache.derby.jdbc.ClientDriverhibernate.connection.url=jdbc:derby://localhost/trails;create=truehibernate.connection.username=anyhibernate.connection.password=valuehibernate.hbm2ddl.auto=update |
MySQL
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.MySQLInnoDBDialecthibernate.connection.driver_class=com.mysql.jdbc.Driverhibernate.connection.url=jdbc:mysql://localhost/trails?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8hibernate.connection.username=roothibernate.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.H2Dialecthibernate.connection.driver_class=org.h2.Driverhibernate.connection.url=jdbc:h2:trailshibernate.connection.username=sahibernate.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.Oracle9Dialecthibernate.connection.driver_class=oracle.jdbc.OracleDriverhibernate.connection.url=jdbc:oracle:thin:@localhost:1521:XEhibernate.connection.username=systemhibernate.connection.password=systemhibernate.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#A10hibernate.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_performance1hibernate.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.PostgreSQLDialecthibernate.connection.driver_class=org.postgresql.Driverhibernate.connection.url=jdbc:postgresql://localhost/trailshibernate.connection.username=postgreshibernate.connection.password=postgreshibernate.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.SQLServerDialecthibernate.connection.driver_class=net.sourceforge.jtds.jdbc.Driverhibernate.connection.url=jdbc:jtds:sqlserver://localhost:1433/trailshibernate.connection.username=sahibernate.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.HSQLDialecthibernate.connection.driver_class=org.hsqldb.jdbcDriverhibernate.connection.url=jdbc:hsqldb:trails;shutdown=truehibernate.connection.username=sahibernate.connection.password=hibernate.hbm2ddl.auto=update |
手动安装Maven依赖包
例如要安装这样一个依赖到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拷贝到X:\Documents and Settings\%USER%\.m2\repository\com\microsoft\sqlserver\sqljdbc4\3.0 中即可.

浙公网安备 33010602011771号