Posts

Showing posts with the label MySQL

Hibernate CRUD operations with example

Read this article to know what is CRUD and how to do CRUD operations in hibernate with example. CRUD stands for Create, Read, Update and Delete. As part of hibernate learning CRUD operations are the most basic operations. In previous examples, I have explained by using the MySQL configuration in Hibernate. But, in the current example, I am explaining by using Oracle as well as MySQL configuration. The choice is yours, use at your convenience. As of you people already know if we have to change the Database vendors no need to rewrite the entire code, it’s just a configuration file change. So, except the hibernate.cfg.xml file remaining all files logic will be common for both of the databases like Oracle or MySQL. Before going to write the hibernate logic, we have small work with the databases either Oracle or MySQL. Execute the below query to create the table in the database. Before going to execute the below query make sure you have connected with the specific Schema in the dat

Exception in thread "main" java.lang.NoClassDefFoundError: javax/transaction/SystemException

Exception in thread "main" java.lang.NoClassDefFoundError: javax/transaction/SystemException error we got in Hibernate 4.3 to work with my MySQL database. We are using hibernate code generation tool in Eclipse and we are able to connect to the database using the Hibernate configuration file. When we try to run code in my Main class application is connecting to the database, but transaction is failing and we got the following error: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Exception in thread "main" java . lang . NoClassDefFoundError : javax / transaction / SystemException at java . lang . Class . forName0 ( Native Method ) at java . lang . Class . forName ( Unknown Source ) at org . jboss . logging . Logger . getMessageLogger ( Logger . java : 2248 ) at org . jboss . logging . Logger . getMessageLogger ( Logger . java : 2214 ) at org . hibernate . cfg . Configuration .< clinit >( Configuration . java : 184 ) at be . comp . permanenti

Caused by: org.hibernate.exception.SQLGrammarException: could not execute query

Caused by: org.hibernate.exception.SQLGrammarException: could not execute query exception we also got in the process of improving application performance. Because, we have upgraded MySQL-connector-java-3.1.10.jar to MySQL-connector-java-5.1.36.jar. After upgrading to the higher version, my application not at all connecting with the Data Base Schema. Because, In my application we are using JNDI data source connection. As per JNDI, MySQL connector jar will not support after MySQL-connector-java-5.1.6.jar. We are using MySQL server version as 5.1. So, I downgraded from MySQL-connector-java-5.1.36.jar to MySQL-connector-java-5.1.6.jar version. Now, Application getting loading Database Schema and started running the application. But, still I am getting the problem in some scenarios where query is not matching with proper MySQL version. Hence, I am again downgraded MySQL jar from MySQL-connector-java-5.1.6.jar to MySQL-connector-java-5.0.8.jar. Now, there are no issues in my application.