This tutorial will teach you how to create customer count using java mysql.this program help you find no of customers.
public void Connect() { try { Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection("jdbc:mysql://localhost/gsm", "root", ""); } catch (ClassNotFoundException ex) { ex.printStackTrace(); } catch (SQLException ex) { ex.printStackTrace(); } }
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { String name = txtname.getText(); String address = txtaddress.getText(); String phone = txtphone.getText(); try { pst = con.prepareStatement("insert into customer(name,address,phone)values(?,?,?)"); pst.setString(1, name); pst.setString(2, address); pst.setString(3, phone); int k = pst.executeUpdate(); if(k==1) { JOptionPane.showMessageDialog(this, "Record Adddeddd"); txtname.setText(""); txtaddress.setText(""); txtphone.setText(""); txtname.requestFocus(); Customer(); } else { JOptionPane.showMessageDialog(this, "Record Failed"); } } catch (SQLException ex) { ex.printstacktrace(); } }
public void Customer() { try { pst = con.prepareStatement("SELECT COUNT(*) AS customerCount FROM customer"); ResultSet rs = pst.executeQuery(); while(rs.next()) { int count = rs.getInt("customerCount"); // int count = rs.getInt(1); txtmsg.setText(String.valueOf(count)); } } catch (SQLException ex) { ex.printstacktrace(); } }
i attached the video link. watch this video this help you create System step by step.
Introduction In this section, we will guide you step by step in the development of an image upload registration system in Java using MySQL and JDBC. In the application, users register…
The Touchable Shop POS (Point of Sale) system is a sophisticated software solution developed using…
Creating a responsive login form is a crucial skill for any web developer. In this…
In this tutorial will teach Laravel 12 CRUD API by step. Laravel 10 CRUD Application …
In this lesson we talk about laravel 12 image uploading and display the image step…
In this tutorial will teach Laravel 12 CRUD Application step by step. Laravel 12 CRUD…