Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
468
Chapter 18 JDBC and Database Connection Pooling
Listing 18.2 FruitTest result (connecting to Sybase on NT)
Prompt> java coreservlets.FruitTest dbhost2.apl.jhu.edu 605741
hall xxxx sybase
Database: Adaptive Server Anywhere
Version: 6.0.2.2188
Comparing Apples and Oranges
============================
quarter apples applesales oranges orangesales topseller
1 32248 $3547.28 18459 $3138.03 Maria
2 35009 $3850.99 18722 $3182.74 Bob
3 39393 $4333.23 18999 $3229.83 Joe
4 42001 $4620.11 19333 $3286.61 Maria
Listing 18.3 FruitTest.java
package coreservlets;
import java.sql.*;
/** A JDBC example that connects to either an Oracle or
* a Sybase database and prints out the values of
* predetermined columns in the "fruits" table.
*/
public class FruitTest {
/** Reads the hostname, database name, username, password,
* and vendor identifier from the command line. It
* uses the vendor identifier to determine which
* driver to load and how to format the URL. The
* driver, URL, username, host, and password are then
* passed to the showFruitTable method.
*/
public static void main(String[] args) {
if (args.length < 5) {
printUsage();
return;
}
String vendorName = args[4];
int vendor = DriverUtilities.getVendor(vendorName);
if (vendor == DriverUtilities.UNKNOWN) {
printUsage();
return;
}
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved