JDBC Draw Backs
Draw Backs of JDBC :
- In JDBC, to establish a simple database connection also, we need to write that code inside try block. And if any exceptions raised then we need to handle those exceptions inside catch block. Here try and catch blocks are mandatory.
- After performing our required task, as a programmer we must close the connection manually, otherwise we may get out of connection error at runtime. Closing the connection and other resource-reallocating code we need to write inside finally block.
- If we are not closing the connection manually then JDBC is not responsible to close the connection automatically.
- After developing the JDBC program, if there is any changes occurred in the database table structure, then our JDBC program doesn't work because we will write static SQL Queries inside program.
So we need to rewrite the SQL commands according to the latest table structure. The re-compilation and re-deployment is mandatory.
- Because of static SQL queries, JDBC will make our applications as database dependent. If we change the database then our applications doesn't work.
- In JDBC, while retrieving the data from database, we will get that data in the form of ResultSet. Programmer is responsible to cover the data from ResultSet into our required objects.
- JDBC will generate database specific exceptions and errors which are not familiar to java programmers.
- In an Enterprise application, the data flow from one layer to another layer will be in the form of objects, but finally while transferring the object(data) from Data-Access layer to database, that object has to convert into text. Because JDBC cannot transfer the objects directly into the database.