i want to create a priority number where an account will e randomly given a unique number. I'm still currently learning java and mysql pardon any mistakes and i hope you'll help me solve this. thanks!
public void add() {
try {
Class.forName("com.mysql.jdbc.Driver"); // MySQL database connection
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/system?" + "user=root&password=");
PreparedStatement pstmt = null;
pstmt = conn.prepareStatement("insert into customer values (?,?,?,?,?,?,?)");
//customer_id
pstmt.setInt(1, 0);
//customer_name
pstmt.setString(2, tf_name.getText());
//customer_address
pstmt.setString(3, tf_address.getText());
//customer_contactqw
pstmt.setString(4, tf_contact.getText());
//customer_email
pstmt.setString(5, tf_email.getText());
//order_priority
pstmt.setInt(6, 1000 + RAND() * 89999); // <-- pls help me here
//customer_date
pstmt.setDate(7, convertUtilDateToSqlDate(dateChooser.getDate()));
//execute the query
pstmt.executeUpdate();
// JOptionPane.showMessageDialog(null, "Successfully added a new record!");
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}