0

I am facing problem connecting DB2 with hibernate .

Error:-

org.hibernate.HibernateException: No DatabaseDialectMapper known for database [DB2/LINUXX8664]

My configuration is:-

String url="jdbc:db2://10.4.0.71:50000/"+databasename2+":retrieveMessagesFromServerOnGetMessage=true;securityMechanism=3;";
                try {
                    cfg = new Configuration()
                            //add these resources from property file 
                            .addResource(ReadProperty.dictProjectVar.get("hbmFilePath"))
                            .setProperty("dialect","org.hibernate.dialect.DB2Dialect")
                            .setProperty("hibernate.connection.driver_class", "com.ibm.db2.jcc.DB2Driver")
                            .setProperty("hibernate.connection.username","db2inst1")
                            .setProperty("hibernate.connection.password","Pyramid123")
                            .setProperty("hibernate.connection.url", url)
                            .setProperty("hibernate.connection.pool_size", "5")
                            .setProperty("hbm2ddl.auto", "create")
                            .setProperty("show_sql","true");
                }
                catch(Exception e) {
                    e.printStackTrace();
                }

I have added the db2jcc and the db2jcc4 jar to my class path. DB is installed on an ubuntu machine and is a trial version.

Thanks, Aditya

aditya rawat
  • 129
  • 2
  • 18
  • Which hibernate Version do you use? Which hibernate jars do you have in your classpath – Jens Sep 05 '18 at 09:17
  • I have a hibernate 3.0.5 defined in my pom.xml and 2 jars db2jcc and db2jcc4 , no other hiberante jar – aditya rawat Sep 05 '18 at 09:26
  • Could it be linked to linux or is the trial version no letting me access the database via code – aditya rawat Sep 05 '18 at 09:28
  • Possible duplicate of [how to connect hibernate and DB2](https://stackoverflow.com/questions/5495866/how-to-connect-hibernate-and-db2) – fantaghirocco Sep 05 '18 at 09:37
  • @fantaghirocco everything is aligned with that answer but i am still encountering dialect problem – aditya rawat Sep 05 '18 at 09:46
  • so the problem is alswere but your question still is a dupe in my opinion – fantaghirocco Sep 05 '18 at 09:49
  • My hibernate is possibly connecting to the DB2 as in the error it states that dialect not known for DB2(My instance name ) and LINUX(My OS name), so the connection problem is not there , Dialect is the main issue here,, – aditya rawat Sep 05 '18 at 09:51

1 Answers1

0

I believe line no 6 should be something like

.setProperty("hibernate.dialect","org.hibernate.dialect.DB2Dialect")

Also you can refer to this link for more info. how to connect hibernate and DB2

Shoaeb
  • 709
  • 7
  • 18