import java.io.*; import java.sql.*; public class Create4JTeeColor { static String[] asColors = { "Beige", "Black", "Blue", "Green", "White", "Yellow" }; static String[] asImages = { "Beige4j.jpeg", "Black4j.jpeg", "Blue4j.jpeg", "Green4j.jpeg", "White4j.jpeg", "Yellow4j.jpeg" }; public static void main(String[] args) { Connection con = null; File fImage; InputStream isImage; int iRowCount = 0; PreparedStatement pstmt = null; Statement stmt = null; // insert DB driver and connection info // end insert try // Attempt to load the JDBC driver { // with newInstance Class.forName( sDriver ).newInstance(); } catch( Exception e ) // error { System.err.println( "Failed to load current driver."); return; } // end catch try { con = DriverManager.getConnection ( sURL, sUsername, sPassword); stmt = con.createStatement(); } catch ( Exception e) { System.err.println( "problems connecting to " + sURL + ":" ); System.err.println( e.getMessage() ); if( con != null) { try { con.close(); } catch( Exception e2 ) {} } return; } // end catch // to allow the program to be run more than once, // attempt to remove the table from the database try { stmt.executeUpdate( "DROP TABLE TeeColor" ); System.out.println( "Table TeeColor was removed."); } catch ( Exception e ) { /* don't care */ } // execute SQL command // to create the table try { // insert Table creation DDL // end insert System.out.println( "Table TeeColor was created."); try { stmt.close(); } catch( Exception e ) {} stmt = null; // insert prepareStatement code // end insert // insert code to load the rows // end insert System.out.println( iRowCount + " Rows inserted into TeeColor."); } catch ( Exception e ) { System.err.println( "problem with SQL sent to " + sURL + ":" ); System. err.println( e.getMessage() ); } finally { if( stmt != null) { try { stmt.close(); } catch( Exception e2 ) {} } try { pstmt.close(); } catch( Exception e ) {} try { con.close(); } catch( Exception e ) {} } // end finally clause } // end main } // end class Create4JTeeColor