我有一个 sqlite 数据库的接口。一切正常,除了两个 JLabel 不会显示它们应该显示的内容。它在 netbeans 中运行,没有例外。但是当我从命令行运行它时,它不会将文本设置为 JLabels,而只有这两个 JLabels(vanOil 和 VanTires)。有人知道为什么吗?
public class MaintenanceDB {
String van = (String) TabbedPane.chooseVan.getSelectedItem();
public void checkVan() throws Exception {
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager
.getConnection("jdbc:sqlite:office.sqlite");
Statement stat = conn.createStatement();
ResultSet rs = stat
.executeQuery("Select * from Maintenance WHERE Van IS " + van
+ ";");
int totalMiles = Integer.parseInt(TabbedPane.vanMiles.getText());
int lastOil = rs.getInt("LastOilChange");
int lastTire = rs.getInt("LastTireRotation");
int tireIndex = 5;
int oilIndex = 5;
int nextTire = lastTire + tireIndex;
int nextOil = lastOil + oilIndex;
boolean checkOil = CheckMaintenance.checkOil(totalMiles, nextOil);
boolean checkTire = CheckMaintenance.checkTire(totalMiles, nextTire);
int oilDiff = Math.abs(nextOil - totalMiles);
int tireDiff = Math.abs(nextTire - totalMiles);
String displayOil = van + " not due for oil change for " + oilDiff
+ " miles.";
String displayTire = van + " not due for tire totation for " + tireDiff
+ " miles.";
if (checkOil) {
displayOil = "**Van " + van + " " + oilDiff
+ " miles overdue for oil change**";
}
if (checkTire) {
displayTire = "**Van " + van + " " + tireDiff
+ " miles overdue for tire rotation*";
}
rs.close();
conn.close();
TabbedPane.vanOil.setText(displayOil);
TabbedPane.vanTires.setText(displayTire);
}
}
*编辑** * ** * ****
if(command.equals(TabbedPane.setMiles.getText())){
try {
MaintenanceDB mdb=new MaintenanceDB();
mdb.checkVan();
} catch (Exception ex) {
Logger.getLogger(CallsEvent.class.getName()).log(Level.SEVERE, null, ex);
}
}