If your DB2 driver supports the JDBC approach (and it does), you need to set the connection properties. There are three ways to do this: through xml, through the hibernate.properties file, and through program configuration (more specifically, see the Hibernate Reference Documentation , chapters 1 and 2. Here is a simple example of how to do this:
Program:
SessionFactory sf = new Configuration() .setProperty("hibernate.connection.driver_class", "com.ibm.db2.jcc.DB2Driver") .setProperty("hibernate.connection.url", "jdbc:db2://yourDbServerUrl:port/databaseName") .setProperty("hibernate.connection.username", "yourUsername") .setProperty("hibernate.connection.password", "yourPassword") .buildSessionFactory();
Via hibernate.properties :
hibernate.connection.driver_class = com.ibm.db2.jcc.DB2Driver hibernate.connection.url = jdbc:db2://yourDbServerUrl:port/databaseName hibernate.connection.username = yourUsername hibernate.connection.password = yourPassword
Alex Abdugafarov
source share