Was ist falsch mit meiner JDBC mySQL-Anweisung? Offenbar ist meine WHERE-Klausel durcheinander geraten. Hinweis: Der erste Wert ist im actionListener definiert und der =-Wert ist die Variable in der Datenbank.
searchBtn.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
list.clearSelection();
//connect to database
String afName= auth_fName.getText();
String aMI = auth_MI.getText();
String alName = auth_lName.getText();
String tField = titleField.getText();
String sField = subjectField.getText();
//PR.111.002 - “Core Java”, Cay Horstmann - AVAILABLE
try
{
Connection conn = Database.getConnection();
Statement s = conn.createStatement();
if (!afName.equals("") && (!aMI.equals ("")) && (!alName.equals(""))&& (!tField.equals("")) && (!sField.equals("")))
{
selectString = "SELECT call_Number, title, auth_lName, auth_fName, auth_MI, availability"
+ "FROM book, transaction"
+ "WHERE aLName = 'auth_LName' AND afName = 'auth_FName' AND aMI = 'auth_MI'"
+ " AND title = 'title' AND sField = 'subject'";
result ="";
}
s = conn.createStatement();
ResultSet rs = s.executeQuery(selectString);
while (rs.next())
{
String call_Number = rs.getString("call_Number");
String title = rs.getString("title");
String auth_lName = rs.getString("auth_lName");
String auth_MI = rs.getString ("auth_MI");
String auth_fName = rs.getString("auth_fName");
String availability = rs.getString("availability");
view = new View (call_Number, title, auth_lName, auth_MI, auth_fName, availability);
vList.add(view);
}
s.close();
conn.close();
list.setListData(vList.toArray());
} catch (Exception ex) {
ex.printStackTrace();
}
}
});