コード例 #1
0
  public myshow() {
    initComponents();

    String sql = "SELECT * FROM city ORDER BY LOWER(city_name)";

    try {
      conn = Connect.ConnectDB();
      pst = conn.prepareStatement(sql);
      rs = pst.executeQuery();
      if (rs.next()) {
        int count = 1;
        do {
          Object item[] = {rs.getString("city_name")};
          if (((DefaultComboBoxModel) cmbox_myshow_select_city.getModel())
                  .getIndexOf(item[0].toString())
              == -1) {
            cmbox_myshow_select_city.addItem(item[0].toString());
          }
          count++;
        } while (rs.next());
      }
      conn.close();
    } catch (SQLException | HeadlessException e) {
      JOptionPane.showMessageDialog(null, e);
    }

    sql = "SELECT * FROM theater ORDER BY LOWER(theater_name)";

    try {
      conn = Connect.ConnectDB();
      pst = conn.prepareStatement(sql);
      rs = pst.executeQuery();
      if (rs.next()) {
        int count = 1;
        do {
          Object item[] = {rs.getString("theater_name")};
          if (((DefaultComboBoxModel) cmbox_myshow_theater_name.getModel())
                  .getIndexOf(item[0].toString())
              == -1) {
            cmbox_myshow_theater_name.addItem(item[0].toString());
          }
          count++;
        } while (rs.next());
      }
      conn.close();
    } catch (SQLException | HeadlessException e) {
      JOptionPane.showMessageDialog(null, e);
    }
    sql = "SELECT * FROM theater ";

    try {
      conn = Connect.ConnectDB();
      pst = conn.prepareStatement(sql);
      rs = pst.executeQuery();
      if (rs.next()) {
        int count = 1;
        do {
          Object item[] = {rs.getString("movie_name")};
          if (((DefaultComboBoxModel) cmbox_myshow_movie_name.getModel())
                  .getIndexOf(item[0].toString())
              == -1) {
            cmbox_myshow_movie_name.addItem(item[0].toString());
          }
          count++;
        } while (rs.next());
      }
      conn.close();
    } catch (SQLException | HeadlessException e) {
      JOptionPane.showMessageDialog(null, e);
    }
  }
コード例 #2
0
 private void formWindowOpened(
     java.awt.event.WindowEvent evt) { // GEN-FIRST:event_formWindowOpened
   conn = Connect.ConnectDB();
 } // GEN-LAST:event_formWindowOpened
コード例 #3
0
 private void formWindowOpened(
     java.awt.event.WindowEvent evt) { // GEN-FIRST:event_formWindowOpened
   conn = Connect.ConnectDB();
   getContentPane().setBackground(Color.getHSBColor(120, 130, 216));
 } // GEN-LAST:event_formWindowOpened
コード例 #4
0
ファイル: Connect.java プロジェクト: srth12/core_java
 public static void main(String[] args) {
   Connect c = new Connect();
   Connection con = c.connect();
   System.out.println(con);
 }