Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
18.4 Applying the Database Utilities
483
Listing 18.8 EmployeeTest.java
package coreservlets;
import java.sql.*;
/** Connect to Oracle or Sybase and print "employees" table. */
public class EmployeeTest {
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;
}
String driver = DriverUtilities.getDriver(vendor);
String host = args[0];
String dbName = args[1];
String url =
DriverUtilities.makeURL(host, dbName, vendor);
String username = args[2];
String password = args[3];
DatabaseUtilities.printTable(driver, url,
username, password,
"employees", 12, true);
}
private static void printUsage() {
System.out.println("Usage: EmployeeTest host dbName " +
"username password oracle|sybase.");
}
}
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