Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Jdbc JDBC-Odbc Connection

Related Tutorials


 
 

Share on Google+Share on Google+

JDBC-Odbc Connection

Advertisement
JDBC-ODBC Connection is a JDBC driver that translates the operation in JDBC into ODBC. For ODBC,it is a normal java application program.

JDBC-ODBC Connection

     

JDBC-ODBC Connection is a JDBC driver that translates the operation in  JDBC into ODBC. For ODBC,it is a normal java application program. This bridge provides JDBC  for database in which an ODBC driver is available. The bridge is represented as sun.jdbc.odbc.The Java contain a defined package and its library to access ODBC.

Understand with Example

In this Tutorial we help you in explaining JDBC Odbc Connection in Java. The code explains you a how creation and closing of connection is done. For this code we have a   JdbcOdbc Connection class. The class contains a main method, that include a list of steps as follow -

   Loading a driver is the first step to be done inside the try block of main method ( ) by calling a Class.forName ( ),this class accept a "sun.jdbc.odbc.jdbcodbc Driver" as argument.

   DriverManager.getConnection ( ) : This establish or built a connection between url and emp table in the database.

 The print print the "New Connection Create..."..The Connection object call a close ( ),return you the connection is closed. The println show the "Connection closed"

In case the exception exists in a try block, the subsequent catch block check and handle the exception. 

JdbcOdbcConnection.java

import java.sql.*;



public class JdbcOdbcConnection {



  public static void main(String args[]) {



  Connection con = null;





  try {



  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");



  con = DriverManager.getConnection("jdbc:odbc:emp");



  System.out.println("New Connection Create ....");

  con.close();

  System.out.println("Connection closed");



  catch (Exception e) {

  System.out.println(e);

  }



  }

}

  
 

Output

New Connection Create ....
Connection closed

Download code

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 19, 2008

Related Tutorials

Discuss: JDBC-Odbc Connection  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:7
ARUNKUMAR.J
January 24, 2013
jdbc

yes
bharath
December 24, 2011
java

it goods
hussain
January 14, 2012
jdbc-odbc connection

sir..when i am making connection with my database table and running my programm in eclipse,then i m getting my frame but cant submit into my database.. i am getting a message like "cannot find output table student".. pls help me sir...thanks
Roshan
April 1, 2012
getting error

getting error at cannot connect http://localhost:8080
vijayratna
July 14, 2012
Driver Problem with JDBC

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified . when i try your JdbcOdbcConnection.java program above error shown in cmd . i m using window 7 64bit Home Basic .plz help me out .
Rizwana Perveen
April 6, 2013
jdbc-odbc connectivity for windows7

please can any one can tell how to connect jdbc to odbc for windows7.My project is struct in that
anis
July 10, 2013
code

thank u
DMCA.com