Posts

Showing posts with the label JDBC

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.

How to retrieve images from database by using JDBC?

How to retrieve images from database table by using the JDBC table? To know about this topic follow the below lines,           For downloading images from database table we no need to create any databases or tables, but we should know the which table and which column contains the images to retrieve. Once you know the table and column to retrieve images, here is the program to retrieve the images from database table. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 package com . javatbrains . jdbc ; import java.io.File ; import java.io.FileNotFoundException ; import java.io.FileOutputStream ; import java.io.IOException ; import java.io.InputStream ; import java.io.OutputStream ; import java.sql.Connection ; import java.sql.DriverManager ; import java.sql.ResultSet ; import java.sql.SQLException ; import java.sql.Stat

JDBC interview questions and answers

1. What is the JDBC? A. Java Database Connectivity (JDBC) is a standard Java API to interact with relational database form Java. JDBC has set of classes and interfaces which can use from Java application and talk to database without learning RDBMS details and using Database specific JDBC Drivers. 2. What are the new features added to JDBC 4.0? A. The major features added in JDBC 4.0 includes:        • Connection management enhancements        • Support for RowId SQL type        • provides SQL DataSet implementation using annotations        • SQL exception handling enhancements        • SQL XML support 3. Explain basic steps in writing a java program using JDBC? A. JDBC makes the interaction with RDBMS simple and interactive. When a java application needs to access database, Loads RDBMS specific JDBC driver because this driver actually communicates with the database. Opens the connection to database which is then used to send SQL statements and get resul