import java.sql.*; public class Create4JTee { public static void main(String[] args) { Connection con = null; Statement stmt = null; String sDriver = "COM.cloudscape.core.RmiJdbcDriver"; String sURL = "jdbc:cloudscape:rmi:jGuru"; String sUsername = "sa"; String sPassword = "admin"; 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 JJJJTee" ); System.out.println( "Table JJJJTee was removed."); } catch ( Exception e ) { /* don't care */ } // execute SQL command // to create the table try { stmt.executeUpdate( "CREATE TABLE JJJJTee (" + "Entry INTEGER NOT NULL, " + "Customer VARCHAR (20) NOT NULL, " + "TSize VARCHAR (10) NOT NULL, " + "TColor VARCHAR (10) NOT NULL, " + "PRIMARY KEY( Entry )" + ")" ); System.out.println( "Table JJJJTee was created."); } catch ( Exception e ) { System.err.println( "problem with SQL sent to " + sURL + ":" ); System.err.println( e.getMessage() ); } finally { try { stmt.close(); } catch( Exception e ) {} try { con.close(); } catch( Exception e ) {} } // end finally clause } // end main } // end class Create4JTee