Java
  Home arrow Java arrow Page 2 - Reading and Writing Data Using JDBC and XM...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

Reading and Writing Data Using JDBC and XML
By: Sams Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 2 stars2 stars2 stars2 stars2 stars / 4
    2006-06-08

    Table of Contents:
  • Reading and Writing Data Using JDBC and XML
  • Database Drivers
  • Connecting to an ODBC Data Source
  • Retrieving Data from a Database Using SQL
  • Writing Data to a Database Using SQL

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Reading and Writing Data Using JDBC and XML - Database Drivers


    (Page 2 of 5 )

    Java programs that use JDBC classes can follow the familiar programming model of issuing SQL statements and processing the resulting data. The format of the database and the platform it was prepared on don't matter.

    This platform- and database-independence is made possible by a driver manager. The classes of the JDBC class library are largely dependent on driver managers, which keep track of the drivers required to access database records. You'll need a different driver for each database format that's used in a program, and sometimes you might need several drivers for versions of the same format.

    JDBC also includes a driver that bridges JDBC and another database-connectivity standard, ODBC.

    The JDBC-ODBC Bridge

    ODBC, Microsoft's common interface for accessing SQL databases, is managed on a Windows system by the ODBC Data Source Administrator.

    This is run from the Control Panel on a Windows system; to get there on most versions of Windows, click Start, Settings, Control Panel, ODBC Data Sources. On Windows XP, choose Start, Control Panel, Performances and Maintenance, Administrative Tools, Data Sources (ODBC).

    The administrator adds ODBC drivers, configures drivers to work with specific database files, and logs SQL use. Figure 20.1 shows the ODBC Data Source Administrator on a Windows system.


    Figure 20.1  The ODBC Data Source Administrator on a Windows XP system.

    In Figure 20.1, the Drivers tabbed dialog box lists all the ODBC drivers present on the system. Many of the drivers are specific to a database company's format, such as the Microsoft Access Driver.

    The JDBC-ODBC bridge allows JDBC drivers to be used as ODBC drivers by converting JDBC method calls into ODBC function calls.

    Using the JDBC-ODBC bridge requires three things:

    • The JDBC-ODBC bridge driver included with Java 2: sun.jdbc.odbc.JdbcOdbcDriver

    • An ODBC driver

    • An ODBC data source that has been associated with the driver using software such as the ODBC Data Source Administrator

    ODBC data sources can be set up from within some database programs. For example, when a new database file is created in Lotus Approach, users have the option of associating it with an ODBC driver.

    All ODBC data sources must be given short descriptive names. The name is used inside Java programs when a connection is made to the database that the source refers to.

    On a Windows system, after an ODBC driver is selected and the database is created, they show up in the ODBC Data Source Administrator. Figure 20.2 shows an example of this for a data source named WorldEnergy.


    Figure 20.2  A listing of data sources in the ODBC Data Sources Administrator.

    The data source WorldEnergy is associated with a Microsoft Access driver, according to Figure 20.2.


    Note - Most Windows database programs include one or more ODBC drivers that correspond to the format. Microsoft Access includes ODBC drivers that can be used to connect to an Access database file.


    More Java Articles
    More By Sams Publishing


       · This article is an excerpt from the book "Sams Teach Yourself Java 2 in 21 Days, 4th...
     

    Buy this book now. This article is excerpted from chapter 20 of the book Sams Teach Yourself Java 2 in 21 Days, 4th Edition, written by Rogers Cadenhead and Laura Lemay (Sams; ISBN: 0672326280). Check it out today at your favorite bookstore. Buy this book now.

    JAVA ARTICLES

    - Deploying Multiple Java Applets as One
    - Deploying Java Applets
    - Understanding Deployment Frameworks
    - Database Programming in Java Using JDBC
    - Extension Interfaces and SAX
    - Entities, Handlers and SAX
    - Advanced SAX
    - Conversions and Java Print Streams
    - Formatters and Java Print Streams
    - Java Print Streams
    - Wildcards, Arrays, and Generics in Java
    - Wildcards and Generic Methods in Java
    - Finishing the Project: Java Web Development ...
    - Generics and Limitations in Java
    - Getting Started with Java Web Development in...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek