The <dotj:sql> tag can be used to execute SQL against your database. It supports various ways to obtain a
connection to the database, including using a J2EE DataSource (not demonstrated here).
SQL Tag (driver, uri, userid, and password specified):
In this first example, we obtain a connection via a DriverManager using the driver, uri, userid, and password properties.
In our case, these values were first obtained manually (via code) from a properties file. Once the query executes, we
pass the results to a <dotj:grid>. Notice that you can force the use of a PreparedStatement by using the
<dotj:parameter> tags.
Messages 20 thru 25
messageID
subject
name
email
forum
22
Welcome!
support
support@dotjonline.com
General
23
Welcome!
support
support@dotjonline.com
New Tags / Features
24
Welcome!
support
support@dotjonline.com
Email Tags
25
Welcome!
support
support@dotjonline.com
Form Tags
SQL Tag (Properties file specified):
In this second example, our connection properties are obtained automatically for us by pointing to a properties file, which
contains each of the connection values.
Messages 26 thru 30
messageID
subject
name
email
forum
26
Welcome!
support
support@dotjonline.com
Format Tags
27
Welcome!
support
support@dotjonline.com
Grid Tags
28
Welcome!
support
support@dotjonline.com
Input / Output Tags
29
Welcome!
support
support@dotjonline.com
Upload Tags
30
Welcome!
support
support@dotjonline.com
Utility Tags
SQL Tag (java.sql.Connection specified):
In this last example, we obtain our connection ourselves and let the tag use it. When doing this, the connection is
kept open and it is up to the JSP developer to close the connection.