Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


February 1997

Portable Database Programming with Java


RSS
Subscribe to Windows IT Pro | See More Jscript Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!
SideBar    Programming with Java

Download the Code Here

At the Microsoft Professional Developer's Conference in March 1996, Microsoft hailed a new era of software development that will concentrate on intranets, the Web, ActiveX, HTML, applets, browsers, and Java. Microsoft emphasized the integration of tool sets for the various versions of Windows and Internet/intranet application development. It also revealed a unified shell and browser that may become a universal client (Internet Explorer--IE--4.0).

If you don't think Microsoft's new direction is relevant to your situation, you need to know that surveys show most organizations will build intranets. As a result, developers face connecting databases to supply content to thousands of Web browser users, even where those databases are not accessible from the Internet. To meet this need, more and more developers are relying on the Java programming language to access SQL databases (for information about the benefits of Java, see the sidebar, "Programming with Java," page 111).

In this article, I describe several aspects of programming SQL databases with Java, including the Open Database Connectivity (ODBC) and Java Database Connectivity (JDBC) APIs. A simple Java program illustrates how to insert data into an ODBC data source. You'll learn how to add interoperability to your Java database programs with adaptive programming, and how to serve many concurrent database users by writing multitier applications in Java.

The Basics of Java
Java is well known for creating Web applets that you download with HTML pages, but you can also use it to program applications, including SQL applications. Java programs are of two types. Java applets are components embedded in Web pages that a browser executes. Java applications are main programs that the Java interpreter, the Java virtual machine, executes. Java supports a distributed, client/server computing model, and today's Web-orientation exemplifies this model. Applets run as clients and conform to strict client security rules. Applications usually execute at a server, but they can run anywhere a Java virtual machine exists. In a typical scenario, a Windows NT server can support PC, Macintosh, OS/2, and other clients. To embed an applet in an HTML document, you specify an <APPLET> tag, but other scenarios will soon appear. Microsoft applications will soon use applets in a way that is similar to how they use Visual Basic custom controls (VBXs), Object Linking and Embedding custom controls (OCXs), and ActiveX controls.

As an Object-Oriented Programming (OOP) language, Java lets you write programs that use inheritance, encapsulation, and data hiding. Java includes I/O streams, exception handling, and sockets for client/server communication.

The Java architecture includes Unicode strings and characters and a security model that makes developing secure clients easier. Java includes packages that are analogous to application frameworks, which you use with C++ compilers. Java's built-in support for threads also simplifies developing multithreaded clients that can exploit ODBC asynchronous processing mode and high-performance JDBC drivers. Java 1.1, released in December 1996, includes Java Beans (interfaces for interoperable components), Remote Method Invocation (RMI), and other interfaces.

ODBC and JDBC
Multidatabase APIs have gained favor with developers working with SQL databases. Microsoft's ODBC and JavaSoft's JDBC let you use one API to write programs that operate on various SQL databases. Java developers can also use Microsoft data access APIs where the target execution environment is 32-bit Windows. Presently, ODBC or JDBC is the best choice for developing multiplatform programs. Let's examine ODBC and JDBC to see what that choice involves.

ODBC is the most widely used call-level interface for accessing SQL databases. JDBC is a new API that provides an object layer that works with ODBC drivers to abstract SQL programming for Java developers.

The ODBC and JDBC architectures include loadable database drivers and a driver manager. Database drivers are conceptually similar to printer drivers because database drivers let you expand a program's functionality without rewriting its source code. The database drivers are libraries that the driver manager invokes when your program connects to an ODBC or JDBC data source. Your program can use drivers that work with a specific database management system (DBMS), such as Oracle, or drivers that connect to ODBC and JDBC servers. Although these servers can connect to multiple data sources, clients use only one driver to connect to the server. This server-based architecture produces a thinner client by replacing multiple drivers, client libraries, and protocol stacks with one driver and network transport. When your code uses ODBC or JDBC, a driver manager validates the arguments in your call and loads the appropriate driver for the data source to which you are connecting. The UNIX and Macintosh versions use shared libraries for the driver manager and drivers, whereas NT, other Windows versions, and OS/2 use DLLs.

Dozens of ODBC drivers already exist, so INTERSOLV developed bridge software for JavaSoft to let JDBC applications use ODBC drivers. Figure 1 illustrates the JDBC architecture that includes drivers, a driver manager, and a bridge for accessing ODBC data sources.

All ODBC and JDBC data access uses SQL queries to define and manipulate database tables. ODBC and JDBC drivers understand the same SQL (ANSI SQL with X/Open escape clauses) and models for query preparation and execution.

   Previous  [1]  2  3  Next 


Top Viewed ArticlesView all articles
10 Reasons to Deploy Windows Vista

The decision to upgrade your XP systems to Vista is simple when you consider features such as easier backup, a great desktop search, and vastly improved security options. ...

10 Reasons Not to Deploy Windows Vista

The decision to upgrade to Vista has to make business sense, but many companies find the costs in training and application compatibility problems outweigh any benefits Vista brings. ...

CES 2009: Ballmer Announces Windows 7, Windows Live, Live Search Milestones

During his first-ever Consumer Electronics Show (CES) 2009 keynote address last night in Las Vegas, Microsoft CEO Steve Ballmer announced the pending public availability of a feature-complete Windows 7, the final version of Windows Live Essentials, and ...


Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Related Events Virtualization Forum: Optimizing Storage, Networks, Desktops, and Security

Cloud Computing Forum: Integrating Software, Server and Storage as a Service into Your Enterprise IT Delivery Model

Virtualization Forum: Optimizing Storage, Networks, Desktops, and Security

Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2009 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing