Adsl web hosting - Using JDBC with Java Applications and Applets 86
Using JDBC with Java Applications and Applets 86 the GUI to insert, delete, and update the database information through the GUI. First, we have our initial code, shown in Listing 5.2. import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; import java.util.*; public class Accounts extends JFrame { private JButton getAccountButton; private JList accountNumberList; private Connection connection; private JTextField accountIDText, usernameText, passwordText, tsText, activeTSText; public Accounts() { try { Class.forName(”com.mysql.jdbc.Driver”).newInstance(); } catch (Exception e) { System.err.println(”Unable to find and load driver”); System.exit(1); } } private void buildGUI() { Container c = getContentPane(); c.setLayout(new FlowLayout()); //Do Account List Vector v = new Vector(); try { Statement statement = connection.createStatement(); ResultSet rs = statement.executeQuery(”SELECT acc_id FROM acc_acc”); while(rs.next()) { v.addElement(rs.getString(”acc_id”)); } rs.close(); } catch(SQLException e) { } accountNumberList = new JList(v); Listing 5.2 Our GUI application. (continues)
Hint: If you are looking for high quality and reliable webspace provider to host and run your jsp hosting application check Sandzak jsp web hosting provider