The most recent projects are Maven, and Maven is said to be a thing. Entrust everything that depends on the jar file to go spicy! Try to use the HA, the effect is also possible!
Today do a database configuration this piece, deliberately to summarize the relevant things out, in case of a rainy day.
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 |
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 |
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.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
Manually installing MAVEN dependency packages
For example, to install such a dependency to the MAVEN local repository:
1. Add this dependency to the project's Pom.xml
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>3.0</version>
</dependency>
2. Execute the install command on the command line
MVN install:install-file-dfile=sqljdbc4-3.0.jar-dgroupid=com.microsoft.sqlserver-dartifactid=sqljdbc4-dversion= 3.0-dpackaging=jar
3. Copy the Sqljdbc4-3.0.jar to this dependent installation directory
Copy the Sqljdbc4-3.0.jar to the X:\Documents and settings\%user%\.m2\repository\com\microsoft\sqlserver\sqljdbc4\3.0.
160929, each database connection configuration and MAVEN dependent installation