How to execute an SQL SELECT statement in a JSP?

To start with the basic concept, let us create an Employees table in the TEST database and create few records in that table as follows − Open a Command Prompt and change to the installation directory as follows − Let us now create a JSP which will make use of to execute an SQL SELECT statement as follows −

What is the difference between executequery and executeupdate in SQL?

Whereas the execute ( ) and executeUpdate ( ) methods discussed in previous sections return primitive data types — a boolean and int , respectively — the method normally used with a SELECT statement, executeQuery ( ), returns a ResultSet object.

How to check if a resultset column contains a null value?

The wasNull() method of the ResultSet interface determines whether the last column read had a Null value. i.e. whenever you read the contents of a column of the ResultSet using the getter methods (getInt(), getString etc…) you can determine whether it (column) contains null values, using the wasNull() method.

How to print null values in a resultset using JDBC?

Following JDBC program establishes connection with the database, inserts a new record with null values, into the MyPlayers table, retrieves its contents into a ResultSet object and, prints the contents of the record that contains null values using the wasNull () method. Connection established……

How do I add a date picker to a JSP page?

Adding a date picker to a JSP page is not specifically connected to JSP. You may do this as doing with plain HTML markup. To add a date picker, you have to choose a good Javascript date picker. As far as I know JqueryUI date picker is good. Here is another demo with Jquery Mobile.

What are CSS selectors and how to use them?

In CSS, selectors are patterns used to select the element (s) you want to style. Use our CSS Selector Tester to demonstrate the different selectors. Selects every element whose href attribute value ends with “.pdf”.

How to parse form data automatically in JSP?

JSP handles form data parsing automatically using the following methods depending on the situation − getParameter () − You call request.getParameter () method to get the value of a form parameter.

You Might Also Like