From the course: Java EE: Servlets and JavaServer Pages (JSP)

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

Register user: Querying database and building response

Register user: Querying database and building response

From the course: Java EE: Servlets and JavaServer Pages (JSP)

Start my 1-month free trial

Register user: Querying database and building response

- [Instructor] Okay, now let's pick up from where we left off. So, we are going to add a method in application DAO. It's already added here, register user, which returns an int and has a parameter of the user object. So, we're going to take all the information extracted out of this user object and save it as a record to the database. Let's get started on it. The first step is to get the connection to the database. So, I'm going to quickly do that the way we have done for the other methods. Done. Now, let's write the insert query. So, I'm going to say string insert query equal to insert into users. That's the table where we want to store all the information. And, say values. So, the first one is username. Then, this password, First name, last name, age, and activity. That's the insert query. So, if you're wondering, these question marks, then, they are basically the place holders for the parameters that we are going to pass to this query. And, as for the JDBC API, we need to pass these…

Contents