Take the FindGrade.java file and modify it so it displays text fields for first
ID: 3831375 • Letter: T
Question
Take the FindGrade.java file and modify it so it displays text fields for first name, last name and age and inserts the person into the database.
Explanation / Answer
Your all code is right, you have to change and add only some of the code in your program:
In the start() I am adding some code
Public void start(Stage primaryStage)
{
//add this for displaying textfield for fname,lname and age
tffname.setEditable(true);
tflname.setEditable(true);
tfage.setEditable(true);
//add insert button on the form to click on this button to insert fields in person table
Button btInsert = new Button(“Insert”);
}
//write insert function
private void insertlpa()
{
try{
String querystring= “insert into person values(?,?,?)”;
PreparedStatement stmt=con.prepareStatement("querystring);
stmt.setString(1,”sara”);//1 specifies the first parameter in the query
stmt.setString(2,"George");
stmt.setInt(3, 20);
int i=stmt.executeUpdate();
System.out.println(i+" records inserted");
con.close();
}catch(Exception e){ System.out.println(e);}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.