0
public void actionPerformed(ActionEvent e) {
try{
String searchQuery = "select BookTitle,ISBN,Price,IsAvailable from BookDetails where BookTitle =?";
PreparedStatement serPST = connector.prepareStatement(searchQuery);
serPST.setString(1,textTitleSearch.getText());
ResultSet serResult = serPST.executeQuery();
int noofbooks = 0;
while(serResult.next()){
noofbooks++;
}
if (noofbooks!=0){
textResultTitle.setText(serResult.getString("BookTitle"));
textResultISBN.setText(Integer.toString((serResult.getInt("ISBN"))));
textResultPrice.setText(Integer.toString((serResult.getInt("Price"))));
textAvailability.setText(serResult.getString("IsAvailable"));
}
else{
JOptionPane.showMessageDialog(null,"Adjust the title");
}
serPST.close();
serResult.close();
}
catch(Exception errSearch){
JOptionPane.showMessageDialog(null, errSearch);
System.out.println(errSearch.getCause());
}
}