63 166
Assignments Done
99,3%
Successfully Done
In July 2018

Answer to Question #58073 in Java | JSP | JSF for Lina

Question #58073
The insert statement is working fine for one table but when I try to insert into two it gives an error. Could you see the code below and give me any feedback?

public void insertContact() throws SQLException {

System.out.println("Please enter your ID");
String id = input.next();
System.out.println("Please enter your phone number");
String number = input.next();

try (Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)) {

ResultSet rs = stmt.executeQuery("SELECT * FROM Contact "
+ "LEFT OUTER JOIN ContactTelNo "
+ "ON Contact.ContactId = ContactTelNo.ContactId");

rs.moveToInsertRow();
rs.updateString(idTable, id);
rs.updateString(numberTable, number);
rs.insertRow();
}
}
Expert's answer

Not answered

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions