Answer the question
In order to leave comments, you need to log in
JavaFx populating a table using case from sqlite database. Is it possible to?
There is an application on SWING, the data is uploaded to the table, while the data from one column changes depending on the conditions:
String sql= "SELECT idrepair as '№',"
+ "case when repairStatus in (0) then 'Not Done' "
+ "when repairStatus in (1) then 'Closed' "
+ "when repairStatus in (2) then 'Open' "
+ "else 'Unknown' end as 'Status'"
+ "FROM repairjournal";
SQLException: no such column: 'case when repairStatus in (0)
private void loadTableViewRepList(ObservableList oblist, Connection conn, TableView table) {
oblist.clear();
try {
String sql = "SELECT * FROM repairjournal";
pst = conn.prepareStatement(sql);
rs = pst.executeQuery();
while (rs.next()) {
oblist.add(new ModelTableRepairList(
rs.getString("idrepair"),
rs.getString("case when repairStatus in (0) then 'Not Done' "
+ "when repairStatus in (1) then 'Closed' "
+ "when repairStatus in (2) then 'Open' "
+ "else 'Unknown' end ")
));
}
table.setItems(oblist);
} catch (SQLException ex) {
Logger.getLogger(RepairListController.class.getName()).log(Level.SEVERE, null, ex);
}
}
Answer the question
In order to leave comments, you need to log in
ResultSet.getString()
as an argument, it can only take the index of a column in the result set or its name. There are no requests there. Read the javadoc.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question