So I am doing a search GUI for full pc systems. The button Get Info is the action button that retrieves the values from the MySQL database and puts them in the jTextfields, but when I press on Get Info, nothing happends, and no errors.
This is the method that gets all the info, and the method is located in class DBAccess which contains all the SQL methods + the connection to database.
public SQLException getpc(fullpc fp) {
ResultSet rs;
connect ();
try {
rs = stmt.executeQuery("SELECT * FROM fullsystems WHERE Name = " + fp.name);
while(rs.next()) {
fp.id = rs.getString("ID");
fp.name = rs.getString("Name");
fp.cpu = rs.getString("Processor");
fp.gpu = rs.getString("Graphics");
fp.ram = rs.getString("Memory");
fp.p = rs.getString("Price");
fp.quant = rs.getString("Available quantity");
}
}
catch (SQLException e) {
return e;
}
return null;
}
And this is the class that contains all the attributes of the table:
package area51project;
public class fullpc {
public String id;
public String name;
public String cpu;
public String gpu;
public String ram;
public String mem;
public String p;
public String quant;
}
And at last, the code that is put into the Get Info button:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
fullpc fp = new fullpc();
DBAccess db = new DBAccess();
fp.name = (String) jComboBox1.getSelectedItem();
db.getpc(fp);
cpu.setText(fp.cpu);
ram.setText(fp.ram);
storage.setText(fp.mem);
gpu.setText(fp.gpu);
price.setText(fp.p);
quantity.setText(fp.quant);
}
The jCombobox1 is just the combobox that is near the Get Info button, so I choose the name of the PC, and then pressing the button shows the info of that PC in the jTextfields. However, Price and Quantity are shown in jLabels.
Help?