You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

sql.html 3.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <html>
  2. <head>
  3. </head>
  4. <body>
  5. <h2><a name="sql">Sql</a></h2>
  6. <h3>Description</h3>
  7. <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>
  8. <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>
  9. <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>
  10. <h3>Parameters</h3>
  11. <table border="1" cellpadding="2" cellspacing="0">
  12. <tr>
  13. <td width="12%" valign="top"><b>Attribute</b></td>
  14. <td width="78%" valign="top"><b>Description</b></td>
  15. <td width="10%" valign="top"><b>Required</b></td>
  16. </tr>
  17. <tr>
  18. <td width="12%" valign="top">driver</td>
  19. <td width="78%" valign="top">Class name of the jdbc driver</td>
  20. <td width="10%" valign="top">Yes</td>
  21. </tr>
  22. <tr>
  23. <td width="12%" valign="top">url</td>
  24. <td width="78%" valign="top">Database connection url</td>
  25. <td width="10%" valign="top">Yes</td>
  26. </tr>
  27. <tr>
  28. <td width="12%" valign="top">userid</td>
  29. <td width="78%" valign="top">Database user name</td>
  30. <td width="10%" valign="top">Yes</td>
  31. </tr>
  32. <tr>
  33. <td width="12%" valign="top">password</td>
  34. <td width="78%" valign="top">Database password</td>
  35. <td width="10%" valign="top">Yes</td>
  36. </tr>
  37. <tr>
  38. <td width="12%" valign="top">src</td>
  39. <td width="78%" valign="top">File containing sql statements</td>
  40. <td width="10%" valign="top">Yes, unless statements enclosed within tags</td>
  41. </tr>
  42. <tr>
  43. <td width="12%" valign="top">autocommit</td>
  44. <td width="78%" valign="top">Auto commit flag for database connection (default false)</td>
  45. <td width="10%" valign="top">No, default "false"</td>
  46. </tr>
  47. </table>
  48. <h3>Examples</h3>
  49. <pre><blockquote>&lt;sql
  50. driver="org.database.jdbcDriver"
  51. url="jdbc:database-url"
  52. userid="sa"
  53. password="pass"
  54. src="data.sql"
  55. /&gt;
  56. </pre></blockquote>
  57. <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>
  58. <blockquote><pre>&lt;sql
  59. driver="org.database.jdbcDriver"
  60. url="jdbc:database-url"
  61. userid="sa"
  62. password="pass"
  63. &gt;
  64. insert
  65. into table some_table
  66. values(1,2,3,4);
  67. truncate table some_other_table;
  68. &lt;/sql&gt;
  69. </pre></blockquote>
  70. <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>
  71. <p>Note that you may want to enclose your statements in
  72. <code>&lt;![CDATA[</code> ... <code>]]&gt;</code> sections so you don't
  73. need to escape <code>&lt;</code>, <code>&gt;</code> <code>&amp;</code>
  74. or other special characters. For exampe:</p>
  75. <blockquote><pre>&lt;sql
  76. driver="org.database.jdbcDriver"
  77. url="jdbc:database-url"
  78. userid="sa"
  79. password="pass"
  80. &gt;&lt;![CDATA[
  81. update some_table set column1 = column1 + 1 where column2 &lt; 42;
  82. ]]&gt;&lt;/sql&gt;
  83. </pre></blockquote>
  84. </body>
  85. </html>