KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > dbtags > preparedstatement > SetColumnTag


1 /*
2  * Copyright 1999,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.taglibs.dbtags.preparedstatement;
17
18 import java.sql.PreparedStatement JavaDoc;
19 import java.sql.SQLException JavaDoc;
20
21 import javax.servlet.jsp.JspTagException JavaDoc;
22
23 /**
24  * <p>Setter for the enclosing preparedstatement tag. Set the
25  * value inside the tag body. Body content <i>will not</i>
26  * be trimmed.</p>
27  * <p>JSP Tag Lib Descriptor
28  * <pre>
29  * &lt;name>setColumn&lt;/name>
30  * &lt;tagclass>org.apache.taglibs.dbtags.preparedstatement.SetColumnTag&lt;/tagclass>
31  * &lt;bodycontent>JSP&lt;/bodycontent>
32  * &lt;info>Setter for the enclosing preparedstatement tag. Set the
33  * value inside the tag body. Body content <i>will not</i>
34  * be trimmed.&lt;/info>
35  * &lt;attribute>
36  * &lt;name>position&lt;/name>
37  * &lt;required>true&lt;/required>
38  * &lt;rtexprvalue>false&lt;/rtexprvalue>
39  * &lt;/attribute>
40  * </pre>
41  *
42  * @author Morgan Delagrange
43  * @see org.apache.taglibs.dbtags.preparedstatement.PreparedStatementImplTag
44  */

45 public class SetColumnTag extends BaseSetterBodyTag {
46
47   public int doEndTag() throws JspTagException JavaDoc {
48
49     PreparedStatement JavaDoc statement = getPreparedStatement();
50
51     try {
52       String JavaDoc string = null;
53
54       if (_attributeName == null) {
55         string = getBodyContent().getString();
56       } else {
57         string = (String JavaDoc) getAttribute(_attributeName);
58       }
59
60       statement.setString(_position,string);
61
62     } catch (SQLException JavaDoc e) {
63       throw new JspTagException JavaDoc(e.toString());
64     }
65     return EVAL_PAGE;
66   }
67
68 }
69
Popular Tags