Esempio n. 1
0
  InsertData(Graphics g, int time) {

    // ***************************************************
    String response = JOptionPane.showInputDialog(null, "INPUT YOUR INTIALS.");
    String initials = response.substring(0, 3);
    Date date = new Date();

    String dateString = "" + date;

    String name = initials;
    String maze = "EASY";
    int score = time;
    try {
      String url = "jdbc:mysql://pascobulldogs.com:3306/web?user=webuser&password=w0506r";

      String sqlInsert =
          "INSERT INTO maze VALUES ('','"
              + name
              + "','"
              + maze
              + "','"
              + score
              + "','"
              + dateString
              + "');";
      g.drawString("SCORE RECORED. REFRESH TO START OVER!", 10, 380);

      // System.out.println(sqlInsert);
      //	System.out.println (url);
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      conn = DriverManager.getConnection(url);
      // cwc added this
      stmt = conn.createStatement();
      stmt.executeUpdate(sqlInsert);
      // i added this
      conn.close();
    } catch (Exception e) {
      // System.err.println ("Cannot connect to database server.");
    } finally {
      if (conn != null) {
        try {
          conn.close();
          //   System.out.println ("Database connection terminated");
        } catch (Exception e) {
          /* ignore close errors */
        }
      }
    }
  }
Esempio n. 2
0
 public void dispose() {
   try {
     stmt.close();
     con.close();
   } catch (SQLException e) {
   }
 }
Esempio n. 3
0
 public static void closeConnect() {
   try {
     con.close();
   } catch (SQLException e) {
     MessageBox.infoBox(e.toString(), "Error in closeConnect");
   }
 }
 public void excluir(Oriundo oriundo) throws SQLException {
   Connection con =
       DriverManager.getConnection(
           new conexao().url,
           new conexao().config.getString("usuario"),
           new conexao().config.getString("senha"));
   PreparedStatement ps = null;
   String sqlExcluir = "DELETE FROM oriundo WHERE codigo=?";
   try {
     ps = con.prepareStatement(sqlExcluir);
     ps.setInt(1, oriundo.getCodigo());
     ps.executeUpdate();
     JOptionPane.showMessageDialog(
         null, "Ecluido Com Sucesso: ", "Mensagem do Sistema - Excluir", 1);
   } catch (NumberFormatException e) {
     JOptionPane.showMessageDialog(
         null, "NumberFormaterExeption Erro: " + e.getMessage(), "ClasseDAO Func.Excluir", 0);
     e.printStackTrace();
   } catch (NullPointerException e) {
     JOptionPane.showMessageDialog(
         null, "NullPointerException Erro: " + e.getMessage(), "ClasseDAO Func. Excluir", 0);
     e.printStackTrace();
   } catch (SQLException e) {
     JOptionPane.showMessageDialog(
         null, "SQLException Erro: " + e.getMessage(), "ClasseDAO Func. Excluir", 0);
     e.printStackTrace();
   } catch (Exception e) {
     JOptionPane.showMessageDialog(
         null, "Exception Erro: " + e.getMessage(), "ClasseDAO Func. Excluir", 0);
     e.printStackTrace();
   } finally {
     ps.close();
     con.close();
   }
 }
  public void connectItems(String query)
        // PRE:  query must be initialized
        // POST: Updates the list of Items based on the query.
      {
    String driver = "org.apache.derby.jdbc.ClientDriver"; // Driver for DB
    String url = "jdbc:derby://localhost:1527/ShopDataBase"; // Url for DB
    String user = "******"; // Username for db
    String pass = "******"; // Password for db
    Connection myConnection; // Connection obj to db
    Statement stmt; // Statement to execute a result appon
    ResultSet results; // A set containing the returned results
    int rowcount; // Num objects in the resultSet
    int i; // Index for the array

    try { // Try connection to db

      Class.forName(driver).newInstance(); // Create our db driver

      myConnection = DriverManager.getConnection(url, user, pass); // Initalize our connection

      stmt =
          myConnection.createStatement(
              ResultSet.TYPE_SCROLL_INSENSITIVE,
              ResultSet.CONCUR_UPDATABLE); // Create a new statement
      results = stmt.executeQuery(query); // Store the results of our query

      rowcount = 0;
      if (results.last()) // Go to the last result
      {
        rowcount = results.getRow();
        results.beforeFirst();
      }
      itemsArray = new Item[rowcount];

      i = 0;
      while (results.next()) // Itterate through the results set
      {
        itemsArray[i] =
            new Item(
                results.getInt("item_id"),
                results.getString("item_name"),
                results.getString("item_type"),
                results.getInt("price"),
                results.getInt("owner_id"),
                results.getString("item_path")); // Creat new Item
        i++;
      }

      results.close(); // Close the ResultSet
      stmt.close(); // Close the statement
      myConnection.close(); // Close the connection to db

    } catch (Exception e) // Cannot connect to db
    {
      System.err.println(e.toString());
      System.err.println("Error, something went horribly wrong in connectItems!");
    }
  }
 private void close(Connection conn) {
   try {
     if (conn != null) {
       conn.close();
     }
   } catch (SQLException e) {
     LOGGER.error("error during closing:" + e.getMessage(), e);
   }
 }
Esempio n. 7
0
 public void run() {
   m_nTrans = 0;
   m_nTrans1Sec = 0;
   m_nTrans2Sec = 0;
   m_nTimeSum = 0;
   if (m_nNumRuns <= 0) return;
   Statement stmt = null;
   try {
     stmt = m_conn.createStatement();
     ResultSet set;
     // get branch count
     log("select max(branch) from " + m_Driver.getBranchName() + "\n", 2);
     set = stmt.executeQuery("select max(branch) from " + m_Driver.getBranchName());
     if (set != null && set.next()) {
       m_nMaxBranch = set.getInt(1);
       set.close();
     }
     // get teller count
     log("select max(teller) from " + m_Driver.getTellerName() + "\n", 2);
     set = stmt.executeQuery("select max(teller) from " + m_Driver.getTellerName());
     if (set != null && set.next()) {
       m_nMaxTeller = set.getInt(1);
       set.close();
     }
     // get account count
     log("select max(account) from " + m_Driver.getAccountName() + "\n", 2);
     set = stmt.executeQuery("select max(account) from " + m_Driver.getAccountName());
     if (set != null && set.next()) {
       m_nMaxAccount = set.getInt(1);
       set.close();
     }
   } catch (SQLException e) {
     log("Error getting table limits : " + e.getMessage() + "\n", 0);
   } finally {
     if (stmt != null)
       try {
         stmt.close();
       } catch (SQLException e) {
       }
     stmt = null;
   }
   //		System.out.println("Thread : " + getName() + " Branch :" + m_nMaxBranch + " Teller : " +
   // m_nMaxTeller + " Account : " + m_nMaxAccount);
   if (m_bRunText) runTextTest();
   if (m_bRunPrepared) runPrepareTest();
   if (m_bRunSProc) runProcTest();
   if (m_bCloseConnection) {
     try {
       m_conn.close();
       log("Thread connection closed", 2);
     } catch (SQLException e) {
     }
   }
   if (m_log != null) m_log.taskDone();
 }
  public void updateTables(String updateQuery1, String updateQuery2, String updateQuery3)
        // PRE:  updateQuery1,updateQuery2, updateQuery3 must be initialized
        // POST: Updates the list of Items based on the querys.
      {
    String driver = "org.apache.derby.jdbc.ClientDriver"; // Driver for DB
    String url = "jdbc:derby://localhost:1527/ShopDataBase"; // Url for DB
    String user = "******"; // Username for db
    String pass = "******"; // Password for db
    Connection myConnection; // Connection obj to db
    Statement stmt; // Statement to execute a result appon
    ResultSet results; // A set containing the returned results
    int i; // Index for the array
    try // Try connection to db
    {

      Class.forName(driver).newInstance(); // Create our db driver

      myConnection = DriverManager.getConnection(url, user, pass); // Initalize our connection

      stmt =
          myConnection.createStatement(
              ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
      stmt.executeUpdate(updateQuery1);

      stmt.executeUpdate(updateQuery2);

      stmt.executeUpdate(updateQuery3);

      results = stmt.executeQuery(previous_query); // Call the previous query

      i = 0;
      while (results.next()) // Itterate through the results set
      {
        itemsArray[i] =
            new Item(
                results.getInt("item_id"),
                results.getString("item_name"),
                results.getString("item_type"),
                results.getInt("price"),
                results.getInt("owner_id"),
                results.getString("item_path"));
        i++;
      }
      results.close(); // Close the ResultSet
      stmt.close(); // Close the statement
      myConnection.close(); // Close the connection to db

    } catch (Exception e) // Cannot connect to db
    {
      System.err.println(e.toString());
      System.err.println("Error, something went horribly wrong! in updateTables");
    }
  }
Esempio n. 9
0
 public void closeDB() {
   try {
     if (statement != null) {
       statement.close();
     }
     if (db != null) {
       db.close();
     }
   } catch (Exception e) {
     System.out.println("Database could not closed");
     e.printStackTrace();
   }
 } // closeDB sonu
  public void windowClosing(WindowEvent ev) {

    try {
      cConn.close();
    } catch (Exception e) {
    }

    fMain.dispose();

    if (bMustExit) {
      System.exit(0);
    }
  }
  public void actionPerformed(ActionEvent e) {
    Object source = e.getSource();

    if (source == bRes) {
      tname.setText("");
      textra.setText("");
    } else {
      if (it.isSelected()) field = 1;
      else if (civil.isSelected()) field = 2;
      else if (mech.isSelected()) field = 3;

      if (tname.getText().equals("") | textra.getText().equals("") | field == 0)
        JOptionPane.showMessageDialog(null, "Please Fill in All Entries!!");
      else {
        String sal = (String) cbsal.getSelectedItem();

        try {
          // Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          // Connection conn=DriverManager.getConnection("jdbc:odbc:go");
          Class.forName("com.mysql.jdbc.Driver").newInstance();
          Connection conn = DriverManager.getConnection("jdbc:mysql:///go", "root", "");
          Statement pst = conn.createStatement();

          pst.executeUpdate(
              "Insert into company values('"
                  + tname.getText()
                  + "','"
                  + textra.getText()
                  + "','"
                  + (String) sal
                  + "','"
                  + field
                  + "','"
                  + tusr.getText()
                  + "','"
                  + tpwd.getText()
                  + "')");
          conn.close();
          String msg =
              "Your Details are Stored. Login again to View Related applicants!  Thank You!!";
          JOptionPane.showMessageDialog(null, msg);
          setVisible(false);
          login ab = new login();

        } catch (Exception exc) {
          JOptionPane.showMessageDialog(null, tname.getText() + " : " + exc);
          System.exit(0);
        }
      }
    }
  }
  private void Update_Table() {
    try {

      String sql = "select * from Bank_001";
      PreparedStatement pst = conn.prepareStatement(sql);
      ResultSet rs = pst.executeQuery();

      table.setModel(DbUtils.resultSetToTableModel(rs));
      conn.close();

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public void actionPerformed(ActionEvent ae) {
    String str = ae.getActionCommand();
    if (str.equals("Ok")) {
      String str1 = (String) jcmname.getSelectedItem();

      Connection con = null;
      Statement stat = null;

      if (str1.equals("Pulsar")
          || str1.equals("CT 100")
          || str1.equals("Discover DTS-i")
          || str1.equals("Wave DTS-i")) {
        try {
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          con = DriverManager.getConnection("Jdbc:Odbc:showroom");
          System.out.println("Got Connection :" + con);
          stat = con.createStatement();
          ResultSet rs = stat.executeQuery("select * from vehicle");
          System.out.println("chk1");
          while (rs.next()) {
            if (str1.equals(rs.getString(1))) {

              tfcap.setText("" + rs.getInt(2));
              tfeng.setText("" + rs.getInt(3));
              tfbhp.setText("" + rs.getInt(4));
              tfvolt.setText("" + rs.getInt(5));
              tfrpm.setText("" + rs.getInt(6));
              tfweight.setText("" + rs.getInt(7));
              tfgear.setText("" + rs.getInt(8));
            }
          }

          stat.close();
          con.close();

        } catch (Exception ex) {
        }

      } else {
        JOptionPane.showMessageDialog(
            null, "Please Choose Model Name", "Error", JOptionPane.ERROR_MESSAGE);
      }
    }

    if (str.equals("can")) {
      this.dispose();
      // new menu(1);
    }
  }
 public List<Oriundo> listar() throws SQLException {
   List<Oriundo> resultado = new ArrayList<Oriundo>();
   conexao propCon = new conexao();
   Connection con =
       DriverManager.getConnection(
           new conexao().url,
           propCon.config.getString("usuario"),
           propCon.config.getString("senha"));
   PreparedStatement ps = null;
   ResultSet rs = null;
   String sqlListar = "SELECT * FROM oriundo Order by codigo DESC";
   Oriundo oriundo;
   try {
     ps = con.prepareStatement(sqlListar);
     rs = ps.executeQuery();
     // if(rs==null){
     // return null;
     // }
     while (rs.next()) {
       oriundo = new Oriundo();
       oriundo.setCodigo(rs.getInt("codigo"));
       oriundo.setDescricao(rs.getString("descricao"));
       oriundo.setData_cadastro(rs.getDate("data_cadastro"));
       oriundo.setDia_fechamento(rs.getInt("dia_fechamento"));
       oriundo.setDia_pag(rs.getInt("dia_pag"));
       resultado.add(oriundo);
     }
   } catch (NumberFormatException e) {
     JOptionPane.showMessageDialog(
         null, "NumberFormaterExeption Erro: " + e.getMessage(), "ClasseDAO Func.Localizar", 0);
     e.printStackTrace();
   } catch (NullPointerException e) {
     JOptionPane.showMessageDialog(
         null, "NullPointerException Erro: " + e.getMessage(), "ClasseDAO Func. Localizar", 0);
     e.printStackTrace();
   } catch (SQLException e) {
     JOptionPane.showMessageDialog(
         null, "SQLException Erro: " + e.getMessage(), "ClasseDAO Func. Localizar", 0);
     e.printStackTrace();
   } catch (Exception e) {
     JOptionPane.showMessageDialog(
         null, "Exception Erro: " + e.getMessage(), "ClasseDAO Func. Localizar", 0);
     e.printStackTrace();
   } finally {
     ps.close();
     con.close();
   }
   return resultado;
 }
Esempio n. 15
0
File: Main.java Progetto: 8CAKE/ALE
  public void systemClose() {

    if (client.isConnected == true) {
      client.disconnect(messageArea, messageInputArea, superUser);
    }

    try {
      if (dbCon != null) {
        dbCon.close();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    System.exit(0);
  }
 public Oriundo localizar(Integer codigo) throws SQLException {
   Connection con =
       DriverManager.getConnection(
           new conexao().url,
           new conexao().config.getString("usuario"),
           new conexao().config.getString("senha"));
   PreparedStatement ps = null;
   ResultSet rs = null;
   String sqlLocalizar = "SELECT * FROM oriundo WHERE codigo=?";
   Oriundo oriundo = new Oriundo();
   try {
     ps = con.prepareStatement(sqlLocalizar);
     ps.setInt(1, codigo);
     rs = ps.executeQuery();
     // if(!rs.next()){
     // return null;
     // }
     oriundo.setCodigo(rs.getInt("codigo"));
     oriundo.setDescricao(rs.getString("descricao"));
     oriundo.setData_cadastro(rs.getDate("data_cadastro"));
     oriundo.setDia_fechamento(rs.getInt("dia_fechamento"));
     oriundo.setDia_pag(rs.getInt("dia_pag"));
     return oriundo;
   } catch (NumberFormatException e) {
     JOptionPane.showMessageDialog(
         null, "NumberFormaterExeption Erro: " + e.getMessage(), "ClasseDAO Func.Localizar", 0);
     e.printStackTrace();
   } catch (NullPointerException e) {
     JOptionPane.showMessageDialog(
         null, "NullPointerException Erro: " + e.getMessage(), "ClasseDAO Func. Localizar", 0);
     e.printStackTrace();
   } catch (SQLException e) {
     JOptionPane.showMessageDialog(
         null, "SQLException Erro: " + e.getMessage(), "ClasseDAO Func. Localizar", 0);
     e.printStackTrace();
   } catch (Exception e) {
     JOptionPane.showMessageDialog(
         null, "Exception Erro: " + e.getMessage(), "ClasseDAO Func. Localizar", 0);
     e.printStackTrace();
   } finally {
     ps.close();
     con.close();
   }
   return oriundo;
 }
Esempio n. 17
0
  // event handling
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == btnok) {
      PreparedStatement pstm;
      ResultSet rs;
      String sql;
      // if no entries has been made and hit ok button throw an error
      // you can do this step using try clause as well
      if ((tf1.getText().equals("") && (tf2.getText().equals("")))) {
        lblmsg.setText("Enter your details ");
        lblmsg.setForeground(Color.magenta);
      } else {

        try {
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          Connection connect = DriverManager.getConnection("jdbc:odbc:student_base");
          System.out.println("Connected to the database");
          pstm = connect.prepareStatement("insert into student_base values(?,?)");
          pstm.setString(1, tf1.getText());
          pstm.setString(2, tf2.getText());
          // execute method to execute the query
          pstm.executeUpdate();
          lblmsg.setText("Details have been added to database");

          // closing the prepared statement  and connection object
          pstm.close();
          connect.close();
        } catch (SQLException sqe) {
          System.out.println("SQl error");
        } catch (ClassNotFoundException cnf) {
          System.out.println("Class not found error");
        }
      }
    }
    // upon clickin button addnew , your textfield will be empty to enternext record
    if (e.getSource() == btnaddnew) {
      tf1.setText("");
      tf2.setText("");
    }

    if (e.getSource() == btnexit) {
      System.exit(1);
    }
  }
 public void atualizar(Oriundo oriundo) throws SQLException {
   Connection con =
       DriverManager.getConnection(
           new conexao().url,
           new conexao().config.getString("usuario"),
           new conexao().config.getString("senha"));
   PreparedStatement ps = null;
   String sqlAtualizar =
       "UPDATE oriundo SET descricao=?, data_cadastro=?, dia_fechamento=?, dia_pag=? WHERE codigo=?";
   try {
     ps = con.prepareStatement(sqlAtualizar);
     ps.setString(1, oriundo.getDescricao());
     ps.setDate(2, oriundo.getData_cadastro());
     ps.setInt(3, oriundo.getDia_fechamento());
     ps.setInt(4, oriundo.getDia_pag());
     ps.setInt(5, oriundo.getCodigo());
     ps.executeUpdate();
     JOptionPane.showMessageDialog(
         null, "Atualizado Com Sucesso: ", "Mensagem do Sistema - Atualizar", 1);
   } catch (NumberFormatException e) {
     JOptionPane.showMessageDialog(
         null, "NumberFormaterExeption Erro: " + e.getMessage(), "ClasseDAO Func.Atualizar", 0);
     e.printStackTrace();
   } catch (NullPointerException e) {
     JOptionPane.showMessageDialog(
         null, "NullPointerException Erro: " + e.getMessage(), "ClasseDAO Func. Atualizar", 0);
     e.printStackTrace();
   } catch (SQLException e) {
     JOptionPane.showMessageDialog(
         null, "SQLException Erro: " + e.getMessage(), "ClasseDAO Func. Atualizar", 0);
     e.printStackTrace();
   } catch (Exception e) {
     JOptionPane.showMessageDialog(
         null, "Exception Erro: " + e.getMessage(), "ClasseDAO Func. Atualizar", 0);
     e.printStackTrace();
   } finally {
     ps.close();
     con.close();
   }
 }
Esempio n. 19
0
  public void login() {
    String driver = "oracle.jdbc.driver.OracleDriver";
    String url = "jdbc:oracle:thin:@localhost:1521:orcl";
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;

    String id, pw, sql;
    try {
      Class.forName(driver);
      con = DriverManager.getConnection(url, "hr", "hr");
      stmt = con.createStatement();
      sql = "select * from chatuser where id = '" + lid.getText() + "'";
      rs = stmt.executeQuery(sql);
      if (rs.next()) {
        pw = rs.getString(2);
        nick = rs.getString(3);
        if (lpw.getText().equals(pw)) {
          jd.setVisible(false);
          setVisible(true);
        } else {
          lpw.setText("일치하지 않습니다.");
        }
      } else {
        lid.setText("일치하지 않습니다.");
      }
    } catch (Exception e1) {
      e1.printStackTrace();
      System.out.println("데이터 베이스 연결 실패!!");
    } finally {
      try {
        if (rs != null) rs.close();
        if (stmt != null) stmt.close();
        if (con != null) con.close();
      } catch (Exception e1) {
        System.out.println(e1.getMessage());
      }
    }
  }
 public void salvar(Oriundo oriundo) throws SQLException {
   Connection con =
       DriverManager.getConnection(
           new conexao().url,
           new conexao().config.getString("usuario"),
           new conexao().config.getString("senha"));
   PreparedStatement ps = null;
   String sqlSalvar =
       "INSERT INTO oriundo (descricao, data_cadastro, dia_fechamento, dia_pag ) VALUES (?, ?, ?, ?)";
   try {
     ps = con.prepareStatement(sqlSalvar);
     ps.setString(1, oriundo.getDescricao());
     ps.setDate(2, oriundo.getData_cadastro());
     ps.setInt(3, oriundo.getDia_fechamento());
     ps.setInt(4, oriundo.getDia_pag());
     ps.executeUpdate();
     // JOptionPane.showMessageDialog(null, "Inserido Com Sucesso: ", "Mensagem do Sistema -
     // Salvar", 1);
   } catch (NumberFormatException e) {
     JOptionPane.showMessageDialog(
         null, "NumberFormaterExeption Erro: " + e.getMessage(), "ClasseDAO Func.Salvar", 0);
     e.printStackTrace();
   } catch (NullPointerException e) {
     JOptionPane.showMessageDialog(
         null, "NullPointerException Erro: " + e.getMessage(), "ClasseDAO Func. Salvar", 0);
     e.printStackTrace();
   } catch (SQLException e) {
     JOptionPane.showMessageDialog(
         null, "SQLException Erro: " + e.getMessage(), "ClasseDAO Func. Salvar", 0);
     e.printStackTrace();
   } catch (Exception e) {
     JOptionPane.showMessageDialog(
         null, "Exception Erro: " + e.getMessage(), "ClasseDAO Func. Salvar", 0);
     e.printStackTrace();
   } finally {
     ps.close();
     con.close();
   }
 }
  private void connect(Connection c) {

    if (c == null) {
      return;
    }

    if (cConn != null) {
      try {
        cConn.close();
      } catch (SQLException e) {
      }
    }

    cConn = c;

    try {
      dMeta = cConn.getMetaData();
      sStatement = cConn.createStatement();

      refreshTree();
    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
Esempio n. 22
0
  private void jButton1ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed

    try {
      Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
      con = DriverManager.getConnection("jdbc:derby:millmanage;create=true", "app", "");

      Object d = day.getSelectedItem();
      Object m = month.getSelectedItem();
      Object y = year.getSelectedItem();
      String names = null;
      String sql3 =
          "select border_name from bazar where amount<>0 and bday='"
              + d.toString()
              + "' and bmonth='"
              + m.toString()
              + "' and byear='"
              + y.toString()
              + "' ";
      pst = con.prepareStatement(sql3);
      rs = pst.executeQuery();

      if (rs.next()) {
        names = rs.getString("border_name");
        nameofbazari.setText(String.valueOf(names));
      }

      String sql =
          "select items,amount from bazar where border_name='"
              + names
              + "' and amount<>0 and bday='"
              + d.toString()
              + "' and bmonth='"
              + m.toString()
              + "' and byear='"
              + y.toString()
              + "' ";
      String sql2 =
          "select sum(amount) from bazar where border_name='"
              + names
              + "' and amount<>0 and bday='"
              + d.toString()
              + "' and bmonth='"
              + m.toString()
              + "' and byear='"
              + y.toString()
              + "' ";
      pst = con.prepareStatement(sql2);
      rs = pst.executeQuery();
      int amount;
      if (rs.next()) {
        amount = rs.getInt(1);
        output.setText(String.valueOf(amount));
      }

      pst = con.prepareStatement(sql);
      rs = pst.executeQuery();
      bazarlist.setModel(DbUtils.resultSetToTableModel(rs));
      pst.close();
      rs.close();
      con.close();

    } catch (Exception e) {
      JOptionPane.showMessageDialog(this, e);
    }
  } // GEN-LAST:event_jButton1ActionPerformed