[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 303
  • Last Modified:

mysql insert statement format

how do you enter these fields into a table called 'register' in mysql using jsp.
strUsername
strPassword
this is what i am trying
ResultSet rs1 = stmt.executeQuery("insert into register(userName, password, fName, lName, dept, phone_no, email, budget) values ('strUserName','strPassword','strFirstName','strLastName','strDept','strPhone','strEmail','strBudget')");
             
0
Raftor
Asked:
Raftor
1 Solution
 
Nick_72Commented:
Your statement looks ok, but there are two things:

when you insert or modify rows in a table you have to use stmt.executeUpdate() instead of executeQuery()

secondly, executeUpdate() returns an int with the number of rows affected instead of a ResultSet.

/Nick
0
 
RaftorAuthor Commented:
Cheers Nick!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now