I´m developing an app using JavaFX and SQLite, it goes well but too slow, and we are starting introducing data to the database
In the operations there aren´t too mch problems, the problems became in the tables, due to the override of the ValueFactory
A solution could be to separate the tables per years or something like that, but I want to know if I´m doing right the process
Here is the overrithe of each column (replace Object by each Model), i use to have 8 colums or more than need to override the method due to are a lot of relations and Ids
idObjectEntradaColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Entrada,String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(CellDataFeatures<Entrada, String> param) {
if(null!=param.getValue().getIdObject()){
String nombreObject = new String();
ObjectGestor mObjectGestor = new ObjectGestor();
Object p = mObjectGestor.selectObjectFromId(param.getValue().getIdObject(),null);
if(null!=p.getnombreObject()){
nombreObject = p.getnombreObject();
} else {
nombreObject = null;
}
if (null==nombreObject){
return null;
} else {
ObservableValue<String> obsString = new ReadOnlyObjectWrapper<String>(nombreObject);
return obsString;
}
} else {
return null;
}
}
});
And the class to search in the database
Connection conn ;
private void initConnection() {
conn = conectarConBDSQLite(route);
}
public Connection conectarConBDSQLite(String ruta) {
Connection c = null;
try {
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:"+ruta);
} catch ( Exception e ) {
UtilsVictor.showAvisoScreen(e);
return null;
}
// System.out.println("Opened database successfully");
return c;
}
public Object selectObjectFromId(Integer id ) {
Object object = new Object();
try {
initConnection();
Statement stmt = conn.createStatement();
ResultSet rs;
rs = stmt.executeQuery("SELECT * FROM objects WHERE idObject = " + id);
while ( rs.next() ) {
object.setidObject(rs.getInt("idObject"));
object.setnombreObject(rs.getString("nombreObject"));
object.setEsDirectaObject(rs.getInt("esDirectaObject"));
object.setTipoObject(rs.getInt("tipoObject"));
}
conn.close();
} catch (Exception e) {
UtilsVictor.showAvisoScreen(e);
}
return object;
}
Is there any mistake?
If u need more infomation ask for it please!
Thanks in advance to all!