Run Hibernate instance in Eclipse
(1) Basic environment: SQL Server 2000ECLIPSE 3.0Hibernate2.1.4
(2) My environment preparation: 1. SQL Server 2000 Account: SA Password: 123456 New Database: Hibernate
2. Unzip hibernate-2.1.4.zip My unzipped to E: /Javasoft/Hibernate-2.1 ,Hibernate-2.1.4.zip's decompression position can be arbitrary, here is listed just to make it easy to describe e: / javasoft /Hibernate-2.1 is called: $ hibernate_home We will run instances in $ hibernate_home / eg
3. SQL Server 2000 JDBC Drive My Driver is: E: /Javasoft/J2SDK1.4.2_04/jre/lib/ext/jtds-0.8-rc1.jar
(3) The following starts 1. Create a new Java Project: TestHibernate2 under Eclipse. Right click on TestHibernate, select "Properties" in the menu -> "Java Build Path" -> "Add External Jars" Need to join the JAR file list as follows: JTDS-0.8-rc1.jar E: /JAVASOFT/J2SDK1.4.2_04/jre/ LIB / EXT / JTDS-0.8-rc1.jar hibernate2.jar $ hibernate_home / hibernate2.jar cglib-full-2.0.1.jar $ hibernate_home / lib / cglib-full-2.0.1.jar Commons-Collections-2.1.jar $ Hibernate_home / lib / commit-collections-2.1.jar Commons-logging-1.0.3.jar $ hibernate_home / lib / commons-logging-1.0.3.jar DOM4J-1.4.JAR $ hibernate_home / lib / dom4j-1.4.jar Ehcache-0.7.jar $ hibernate_home / lib / ehcache-0.7.jar jta.jar $ hibernate_home / lib / jta.jar log4j-1.2.8.jar $ hibernate_home / lib / log4j-1.2.8.jar odmg-3.0.jar Hibernate_home / lib / odmg-3.0.jar
3. Import example $ hibernate_home / EG to TestHibernate / SRC
4. Import hibernate.properties and log4j.properties to TestHibernate / src, these two files can be found under $ hibernate_home / src
The file structure is as shown in the figure:
5. Hibernate.properties default configuration of the database is in hibernate.properties HypersonicSQL, all of them commented as follows: # hibernate.dialect net.sf.hibernate.dialect.HSQLDialect # hibernate.connection.driver_class org.hsqldb.jdbcDriver #hibernate. connection.username sa # hibernate.connection.password # hibernate.connection.url jdbc: hsqldb: hsql: // localhost # hibernate.connection.url jdbc: hsqldb: test # hibernate.connection.url jdbc: hsqldb :. found ## MS SQL Server
# hibernate.dialect net.sf.hibernate.diaalect.sqlserverdiaalect # Hibernate.Connection.Username Sa # Hibernate.Connection.password sa
## jsql driver # hibernate.connection.driver_class com.jnetdirect.jsql.jsqldriver # hibernate.connection.URL JDBC: jsqlconnect: // 1E1 / TEST
Modified to ## MS SQL Server
Hibernate.diaract net.sf.hibernate.diaalect.sqlserverdiaalect hibernate.Connection.username sa hibernate.connection.password 123456
## jsql driver hibernate.connection.driver_class net.sourceForge.jtds.jdbc.driver hibernate.Connection.URL JDBC: JTDS: SQLSERVER: // localhost: 1433 / Hibernate
6. Ok, you can run this example.