Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
JDBC vs ORM 
 

In this section we will examine the differences and similarities between JDBC and ORM technologies.

 

JDBC vs ORM

                         

In this section we will examine the differences and similarities between JDBC and ORM technologies. Both these technologies are used to save the data into persistence storage for future reference.

What is JDBC?

JDBC stands for Java Database Connectivity, is a set of Java API for accessing the relational databases from Java program. The Java API enables the programmers to execute the SQL statements against the JDBC complaint database.

JDBC allows the programmers to quickly develop small Java applications that interact with the databases. To develop an application programmer has to develop the code to connect to the database and then write the code to execute the query. Once the query is successfully executed and result is retrieved from the database, programmer can read the data programmatically from the result set object. Here is the simple example of JDBC example program.

 

import  java.sql.*;

public class  AllTableName{
   public static void  main(String[] args) {
     System.out.println( "Listing all table name in Database!" );
     Connection con =  null ;
     String url =  "jdbc:mysql://localhost:3306/" ;
     String db =  "jdbctutorial" ;
     String driver =  "com.mysql.jdbc.Driver" ;
     String user =  "root" ;
     String pass =  "root" ;
     try {
       Class.forName(driver);
       con = DriverManager.getConnection(url+db, user, pass);
       try {
         DatabaseMetaData dbm = con.getMetaData();
         String[] types = { "TABLE" };
         ResultSet rs = dbm.getTables(null,null, "%" ,types);
         System.out.println( "Table name:" );
         while  (rs.next()){
           String table = rs.getString( "TABLE_NAME" );
           System.out.println(table);
           con.close();
         }
       }
       catch  (SQLException s){
         System.out.println( "No any table in the database" );
       }
     }
     catch  (Exception e){
       e.printStackTrace();
     }
   }
}

Above program retrieves the names of all tables present in the database and then displays on the console.

Advantages of JDBC

  • Clean and easily for small programs
  • JDBC provides good performance with large amount of data
  • Small JDBC programs can be developed very easily
  • Very good for small applications

Disadvantages of JDBC

  • JDBC is not easily if it is used in large projects. There is a big programming overhead.
  • Programmer must hardcode the Transactions and concurrency code in the application.
  • Handling the JDBC connections and properly closing the connection is also a big issue. Properly closing the connection is must.
  • JDBC is not good for big applications

What is ORM?

ORM stands for Object Relational Mapping, is another technology to access the data databases. Here business object is directly mapped to the database tables with the help of ORM framework.

Here are the benefits of ORM technology

  • No need to deal with the SQL Queries to save and retrieve the data
  • Simple configuration
  • Standardized API to persist the business objects
  • Fast development of application
  • Concurrency support
  • Excellent cashing support for better performance of the application
  • Injected transaction management
  • Configurable logging
  • Easy to learn and use

Disadvantages of ORM

  • Slow performance in case of large batch updates
  • Little slower than JDBC 

                         

» View all related tutorials
Related Tags: c ide jpa application io sed applications this id app ie base bi e il it section li as out

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.