public class TableDisplay extends JFrame { private Connection connection; private JTable table; public TableDisplay() { // The URL specifying the Books database to which // this program connects using JDBC to connect to a // Microsoft ODBC database. String url = "jdbc:odbc:Books"; String username = "anonymous"; String password = "guest";
// Load the driver to allow connection to the database try { Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
connection = DriverManager.getConnection( url, username, password ); } catch ( ClassNotFoundException cnfex ) { System.err.println( "Failed to load JDBC/ODBC driver." ); cnfex.printStackTrace(); System.exit( 1 ); // terminate program } catch ( SQLException sqlex ) { System.err.println( "Unable to connect" ); sqlex.printStackTrace(); }
这个程序多次出现的try、catch是什么意思?版主,我仔细看书了,但书上没有说。。。。。。问一下不过份吧