July 2005
Intermediate to advanced
1032 pages
27h 10m
English
In the previous section, I mentioned that the DriverManager.getConnection() method will throw an exception whenever it fails. Listing 13.3 shows the second JDBC client. This version is nearly identical to client1.java, except that client1, ignored any exceptions and in client2, you will intercept them and produce friendlier error messages.
1 // 2 // File: client2.java 3 // 4 5 import java.sql.*; 6 7 public class client2 8 { 9 public static void main( String args[] ) 10 { 11 String driver = "org.postgresql.Driver"; 12 String url = "jdbc:postgresql:movies"; 13 String user = "korry"; 14 String pwd = "cows"; 15 16 try 17 { 18 Class.forName( driver ); 19 } 20 catch( ClassNotFoundException ... |
Read now
Unlock full access