craigmcc 01/01/22 20:08:18
Modified: src/doc/userGuide building_model.xml
Log:
Clean up the data source example to be a little more clear. Also, left justify
the <pre> block so that a smaller font is not necessary.
Submitted by: Andrew Semprebon <[EMAIL PROTECTED]>
PR: BugRat Bug Report #787
Revision Changes Path
1.10 +15 -11 jakarta-struts/src/doc/userGuide/building_model.xml
Index: building_model.xml
===================================================================
RCS file: /home/cvs/jakarta-struts/src/doc/userGuide/building_model.xml,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- building_model.xml 2001/01/22 04:44:07 1.9
+++ building_model.xml 2001/01/23 04:08:18 1.10
@@ -229,26 +229,30 @@
After the datasource is defined, here is an example of establishing a
connection
from within a Action perform method.
</p>
- <p>
-<pre><font size="-1">public ActionForward perform(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) {
+<pre>
+ public ActionForward perform(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) {
try {
- DataSource dataSource = servlet.findDataSource(null);
- Connection myConnection = dataSource.getConnection();
+ javax.sql.DataSource dataSource = servlet.findDataSource(null);
+ java.sql.Connection myConnection = dataSource.getConnection();
//do what you wish with myConnection
}
catch (SQLException sqle) {
- sqle.printStackTrace();
+ getServlet().log("Connection.process", sqle);
}
finally {
//enclose this in a finally block to make
//sure the connection is closed
- myConnection.close();
+ try {
+ myConnection.close();
+ } catch (SQLException e) {
+ getServlet().log("Connection.close", e);
+ }
}
- }</font></pre>
- </p>
+ }
+</pre>
<p align="center">
Next: <a href="building_view.html">Building View Components</a>