Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
486
Chapter 18 JDBC and Database Connection Pooling
Listing 18.12 EmployeeTest2 result (connecting to Sybase on NT)
Prompt> java coreservlets.EmployeeTest2 dbhost2 605741
hall xxxx sybase
id | firstname | lastname | language | salary
1 | Wye | Tukay | COBOL | 42500.0
2 | Britt | Tell | C++ | 62000.0
3 | Max | Manager | none | 15500.0
4 | Polly | Morphic | Smalltalk | 51500.0
5 | Frank | Function | Common Lisp | 51500.0
6 | Justin | Timecompiler | Java | 98000.0
7 | Sir | Vlet | Java | 114750.0
8 | Jay | Espy | Java | 128500.0
| | | | | | | | |
Listing 18.13 EmployeeCreation.java
package coreservlets;
import java.sql.*;
/** Make a simple "employees" table using DatabaseUtilities. */
public class EmployeeCreation {
public static Connection createEmployees(String driver,
String url,
String username,
String password,
boolean close) {
String format =
"(id int, firstname varchar(32), lastname varchar(32), " +
"language varchar(16), salary float)";
String[] employees =
{"(1, 'Wye', 'Tukay', 'COBOL', 42500)",
"(2, 'Britt', 'Tell', 'C++', 62000)",
"(3, 'Max', 'Manager', 'none', 15500)",
"(4, 'Polly', 'Morphic', 'Smalltalk', 51500)",
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