title: How to connect a java program to Derby in netbeans 7.2.1
body: <p>im a novice programmer and i wanna know what is the basic way to connect a java program to Derby in netbeans 7.2.1. my prof asked me to make a program that lets me add, delete, save, search and edit entries from a table. i already know how to make a GUI java program in netbeans and how to make a database on netbeans too. i just want to know what are the basic codes to include in a program to enable it to connect on a database on netbeans 7.2.1. thank you for your time reading my question.</p>
  
  <p><pre></p>
  
  <code>public void connection(){
      try{
              Class.forName("org.apache.derby.jdbc.ClientDriver");
              String myDb = "jdbc:derby://localhost:1527/HWtrial";
              Connection DBconn = DriverManager.getConnection(myDb, "","");
              s1 = DBconn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
  
              result = s1.executeQuery("SELECT * from HWSTUD");
              result.next();
  
              result.last();
          }catch(Exception ex){
              JOptionPane.showMessageDialog(null,"Cannot Connect to Database", "Error Message", JOptionPane.OK_OPTION);
            };
  }
  </code></pre>
  
  <p></p>