July 2005
Intermediate to advanced
1032 pages
27h 10m
English
The next client executes a hard-coded query, intercepts any errors, and prints the result set. I've factored most of the code into separate methods to make it easier to follow. Listing 13.5 shows client3.java.
1 //
2 // File: client3.java
3 //
4
5 import java.sql.*;
6
7 public class client3
8 {
9 public static void main( String args[] )
10 {
11 Class driverClass = loadDriver( "org.postgresql.Driver" ); 12 13 if( driverClass == null ) 14 return; 15 16 if( args.length != 1 ) 17 { 18 System.err.println( "usage: java client3 <url>" ); 19 return; 20 } 21 22 Connection con = connectURL( args[0] ); 23 24 if( con != null ) 25 { 26 ResultSet result = execQuery( con, "SELECT * FROM tapes;" ... |
Read now
Unlock full access