各数据库连接maven配置

Derby

dbdrivermavendependency

<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

MySQLthrowsanEOFExceptionwhenthedatabaseconnectionhasbeenclosedaftertheleasehasexpired,butitworksagainonsubsequentrequests.

ThereisareportedissuewithDBCPandtheMySQLdriver.ChecktheJIRAissueformoreinfoandapossiblesolutionhttp://jira.codehaus.org/browse/TRAILS-85

dbdrivermavendependency

<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&amp;useUnicode=true&amp;characterEncoding=utf-8

hibernate.connection.username=root

hibernate.connection.password=

hibernate.hbm2ddl.auto=update

H2

dbdrivermavendependency

<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

dbdrivermavendependency

<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

#TheOracleJDBCdriverdoesn'tlikepreparedstatementcachingverymuch.

hibernate.statement_cache.size=0

#orbachingwithBLOBsverymuch.

hibernate.jdbc.batch_size=0

#Afterawhile,Oraclethrowsthisexception:toomanyopencursors

#DisablePreparedStatementcachingfortheconnectionpooltoo.

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

hibernate.dbcp.ps.maxIdle=0

#Stopinghibernatefromusingthecolumn-namesinqueriestoretrievedatafromtheresultsets

#Moreinfoinhttp://www.jroller.com/page/dashorst?entry=hibernate_3_1_something_performance1

hibernate.jdbc.wrap_result_sets=true

PostgreSQL.

dbdrivermavendependency

<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

MicrosoftSQLServer

dbdrivermavendependency

<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

dbdrivermavendependency

<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

相关推荐