Hi, i'm trying to create a digital agenda where i store people's name and phone numbers.
I succeded in inserting data from my form ( created with java fxml ) in my database, but i can't display the data from the database in a label.
The last label ("labelDone.setText("Done!");") works fine, but the label ("labelContact.setText(Integer.toString(stmt.executeUpdate(sql1)));") doesn't work. It works if i move it down next to labelDone but i need it up there where is my sql statement. What can i do in this case?
I think maybe you are using the wrong method. Select is not an update. You want to execute a query. After executing the query a resultset or some kind of data object will be returned. You get your data from that.
This is the area of code we're talking about:
First, in line 37, print something that will indicate your error. Otherwise your errors are just disappearing.
Next, you are performing an executUpdate() in line 29, but you're not updating anything. You could try
if you want to see how many records exists and use this code (in some form):
Does that make sense to you?
All things are lawful, but not all things are profitable.