You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by dg...@apache.org on 2003/11/05 05:52:42 UTC
cvs commit: jakarta-commons/dbutils/xdocs index.xml
dgraham 2003/11/04 20:52:42
Modified: dbutils/xdocs index.xml
Log:
Moved the example explanation after the code to make it
clearer.
Revision Changes Path
1.2 +27 -13 jakarta-commons/dbutils/xdocs/index.xml
Index: index.xml
===================================================================
RCS file: /home/cvs/jakarta-commons/dbutils/xdocs/index.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- index.xml 2 Nov 2003 19:15:24 -0000 1.1
+++ index.xml 5 Nov 2003 04:52:42 -0000 1.2
@@ -86,40 +86,54 @@
<section name="Example Usage">
<p>
-The core classes in DbUtils are
+The core classes/interfaces in DbUtils are
<code><a href="apidocs/org/apache/commons/dbutils/QueryRunner.html">QueryRunner</a></code>
and
-<code><a href="apidocs/org/apache/commons/dbutils/ResultSetHandler.html">ResultSetHandler</a></code>
+<code><a href="apidocs/org/apache/commons/dbutils/ResultSetHandler.html">ResultSetHandler</a></code>.
The following example demonstrates how these classes are used together.
</p>
<pre>
DataSource ds = // somehow get DataSource;
-// 1. Configure QueryRunner with the DataSource
-// Note that QueryRunner has methods that take a
-// java.sql.Connection so you are not required to
-// use DataSources.
+// Step 1.
QueryRunner run = new QueryRunner(ds);
-// 2. Implement the ResultSetHandler interface or use
-// one of the provided implementations. This one converts a
-// ResultSet row into a bean.
+// Step 2.
ResultSetHandler h = new BeanHandler(Person.class);
-// 3. Execute the SQL statement with one replacement parameter and
-// return the results in a new Person object (generated by the handler
-// in step 2).
+// Step 3.
Person p = (Person) run.query("SELECT * FROM Person WHERE name=?", "John Doe", h);
+
</pre>
+<p>Explanation</p>
+<ol>
+ <li>
+ Configure QueryRunner with the DataSource.
+ Note that QueryRunner has methods that take a
+ java.sql.Connection so you are not required to
+ use DataSources.
+ </li>
+ <li>
+ Implement the ResultSetHandler interface or use
+ one of the provided implementations. This one converts a
+ ResultSet row into a bean.
+ </li>
+ <li>
+ Execute the SQL statement with one replacement parameter and
+ return the results in a new Person object (generated by the handler
+ in step 2).
+ </li>
+</ol>
+
</section>
<section name="Interaction With Other Packages">
<p>DbUtils relies on these packages:</p>
<ul>
<li>Java 1.2 (or later)</li>
- <li>JDBC 1.2 (or later)</li>
+ <li>JDBC 2.0 (or later)</li>
</ul>
</section>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org