|
- <html>
- <head>
- </head>
- <body>
-
- <h2><a name="sql">Sql</a></h2>
- <h3>Description</h3>
- <p>Executes a series of sql statement via JDBC to a database. Statements can either be read in from a text file using the src attribute or from between the enclosing sql tags.</p>
-
- <p>Multiple statements can be set and each statement is delimited from the next use a semi-colon. Individual lines within the statements can be commented using either -- or // at the start of the line.</p>
-
- <p>The auto-commit attribute specifies whether auto commit should be turned on or off whilst executing the statements. If auto-commit is turned on each statement will be executed and commited. If it is turned off the statements will all be executed as one transaction.</p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td width="12%" valign="top"><b>Attribute</b></td>
- <td width="78%" valign="top"><b>Description</b></td>
- <td width="10%" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td width="12%" valign="top">driver</td>
- <td width="78%" valign="top">Class name of the jdbc driver</td>
- <td width="10%" valign="top">Yes</td>
- </tr>
- <tr>
- <td width="12%" valign="top">url</td>
- <td width="78%" valign="top">Database connection url</td>
- <td width="10%" valign="top">Yes</td>
- </tr>
- <tr>
- <td width="12%" valign="top">userid</td>
- <td width="78%" valign="top">Database user name</td>
- <td width="10%" valign="top">Yes</td>
- </tr>
- <tr>
- <td width="12%" valign="top">password</td>
- <td width="78%" valign="top">Database password</td>
- <td width="10%" valign="top">Yes</td>
- </tr>
- <tr>
- <td width="12%" valign="top">src</td>
- <td width="78%" valign="top">File containing sql statements</td>
- <td width="10%" valign="top">Yes, unless statements enclosed within tags</td>
- </tr>
- <tr>
- <td width="12%" valign="top">autocommit</td>
- <td width="78%" valign="top">Auto commit flag for database connection (default false)</td>
- <td width="10%" valign="top">No, default "false"</td>
- </tr>
- </table>
-
- <h3>Examples</h3>
- <pre><blockquote><sql
- driver="org.database.jdbcDriver"
- url="jdbc:database-url"
- userid="sa"
- password="pass"
- src="data.sql"
- />
- </pre></blockquote>
-
- <p>Connects to the database given in url as the sa user using the org.database.jdbcDriver and executes the sql statements contained within the file data.sql</p>
-
- <blockquote><pre><sql
- driver="org.database.jdbcDriver"
- url="jdbc:database-url"
- userid="sa"
- password="pass"
- >
- insert
- into table some_table
- values(1,2,3,4);
-
- truncate table some_other_table;
- </sql>
- </pre></blockquote>
-
- <p>Connects to the database given in url as the sa user using the org.database.jdbcDriver and executes the two sql statements inserting data into some_table and truncating some_other_table</p>
-
- <p>Note that you may want to enclose your statements in
- <code><![CDATA[</code> ... <code>]]></code> sections so you don't
- need to escape <code><</code>, <code>></code> <code>&</code>
- or other special characters. For exampe:</p>
-
- <blockquote><pre><sql
- driver="org.database.jdbcDriver"
- url="jdbc:database-url"
- userid="sa"
- password="pass"
- ><![CDATA[
-
- update some_table set column1 = column1 + 1 where column2 < 42;
-
- ]]></sql>
- </pre></blockquote>
-
-
- </body>
- </html>
|