This tutorial will teach you Jdbc Search step by step.
Connection con;
PreparedStatement pst;
public void Connect()
{
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost/studcrud","root","");
} catch (ClassNotFoundException ex) {
} catch (SQLException ex) {
} The System Shall be able to search the record by entering the relavent student id.paste the code inside the
search button.
try {
pst = con.prepareStatement("select id,stname,course from records where id=? ");
int id = Integer.parseInt(txtid.getText());
pst.setInt(1, id);
ResultSet rs1 = pst.executeQuery();
if(rs1.next()==false)
{
JOptionPane.showMessageDialog(this, "Sorry Record Not Found");
txtname.setText("");
txtcourse.setText("");
txtid.requestFocus();
}
else
{
txtname.setText(rs1.getString("stname"));
txtcourse.setText(rs1.getString("course"));
}
} catch (SQLException ex) {
Logger.getLogger(SearchJdbc.class.getName()).log(Level.SEVERE, null, ex);
}
Inventory Management POS systems are now an essential part of modern businesses such as bookshops,…
If you're just beginning to learn Java GUI programming creating an Water System Calculator is a fantastic project for…
GitHub is a powerful tool used by teams and developers around the globe. This guide is…
It's like having a super-smart buddy that is always there to help you write stories,…
The UK is known for its rich history, diverse culture, and most of all its…
Do you have a plan for your next holiday? Being aware of the Bank Holidays within the…