import java.sql.*; import java.util.*; public class PrepareAlt { static String[] asDOW = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" }; static String[] asLDOW = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" }; Connection con; int ndx, iRowCount; PreparedStatement pstmt1 = null, pstmt2 = null; ResourceBundle rbConnect; ResultSet rs; Statement stmt; String sDriver, sDriverKey = "CSDriver", sPassword, sPasswordKey ="CSPassword", sQuery = // insert code for query // end insert srbName = "ConnectU", sUpdate1 = // insert code for first update // end insert sUpdate2 = // insert code for second update // end insert sURL, sURLKey="CSURL", sUserID, sUserIDKey = "CSUserID"; // column value holders int iCups, iEntry; String sCustomer = null, sDOW = null, sLDOW = null, sType = null; public PrepareAlt() { try // get the PropertyResourceBundle { rbConnect = ResourceBundle.getBundle( srbName ); sDriver = rbConnect.getString( sDriverKey ); sPassword = rbConnect.getString( sPasswordKey ); sURL = rbConnect.getString( sURLKey ); sUserID = rbConnect.getString( sUserIDKey ); } catch( MissingResourceException mre ) { System.err.println( "ResourceBundle problem for " + srbName + ", program ends." ); System.err.println("Specific error: " + mre.getMessage() ); return; // exit on error } 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, sUserID, sPassword); stmt = con.createStatement(); } catch ( SQLException SQLe) { ReportSQLError( SQLe ); if( con != null) { try { con.close(); } catch( Exception e ) {} } return; } // end catch try { // Add new LDOW column // insert code to ALTER TABLE and print // end insert // prepare the statements // insert code to prepare both statements // end insert // Load LDOW columns // insert code to load LDOW column values // end insert // Update "JustJoe" values to "Jus'Joe" // insert code to update any Type column // containing "JustJoe" to "Jus'Joe" // end insert // Report table Data // insert code to get and report all data // for all rows of JJJJData // end insert } // end try catch ( SQLException SQLe) { ReportSQLError( SQLe ); } catch (Exception e) { e.printStackTrace(); } finally { try { stmt.close(); } catch( Exception e ) {} if( pstmt1 != null) { try { pstmt1.close(); } catch( Exception e ) {} } if( pstmt2 != null) { try { pstmt2.close(); } catch( Exception e ) {} } try { con.close(); } catch( Exception e ) {} } // end finally clause } // end constructor public void ReportSQLError( SQLException SQLe ) { System.err.println( "Problem:" ); System.err.println( SQLe.getMessage() ); System.err.println( "SQL State: " + SQLe.getSQLState() ); } // end ReportSQLError public static void main (String args[]) { new PrepareAlt(); } // end main } // end class PrepareAlt