KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > smile > stored > s_insertRelatedLinkByItemID


1 package smile.stored;
2
3 import java.util.*;
4 import java.sql.*;
5
6 /**
7  * s_insertRelatedLinksByItemID is an implements the ProcedureInterface and is a
8  * sub-class of StoredProcedure. This class inserts related links in the
9  * database. Copyright 2002 Smile Les motoristes Internet http://www.smile.fr/
10  * Contact cofax@smile.fr for further information
11  *
12  * @author Smile Les motoristes Internet
13  * @created March 22, 2002
14  */

15 public class s_insertRelatedLinkByItemID extends StoredProcedure implements ProcedureInterface {
16
17     String JavaDoc ItemID;
18
19     String JavaDoc link;
20
21     String JavaDoc text;
22
23     String JavaDoc rank;
24
25     /**
26      * Constructor for the s_insertRelatedLinkByItemID object
27      */

28     public s_insertRelatedLinkByItemID() {
29     }
30
31     /**
32      * Description of the Method
33      *
34      * @param initData
35      * Description of the Parameter
36      * @param con
37      * Description of the Parameter
38      */

39     public void init(HashMap initData, Connection con) {
40         // on initialise le hashmap de donnees et la connection de l'objet
41
super.init(initData, con);
42         // on initialise les propprietes de l'objet
43
ItemID = utils.getString(data, "ITEMID", "");
44         link = utils.getString(data, "LINK", "");
45         text = utils.getString(data, "TEXT", "");
46         rank = utils.getString(data, "RANK", "");
47     }
48
49     /**
50      * Description of the Method
51      *
52      * @exception SQLException
53      * Description of the Exception
54      */

55     public void checkAction() throws SQLException {
56     }
57
58     /**
59      * Description of the Method
60      *
61      * @exception SQLException
62      * Description of the Exception
63      */

64     public void checkParams() throws SQLException {
65         if (ItemID.equals("") || link.equals("") || text.equals("") || rank.equals("")) {
66             throw new SQLException("ERROR: REQUIRED FIELDS WERE NOT SENT.");
67         }
68     }
69
70     /**
71      * Description of the Method
72      *
73      * @exception SQLException
74      * Description of the Exception
75      */

76     public void executeAction() throws SQLException {
77         StringBuffer JavaDoc v_sbInsert = new StringBuffer JavaDoc();
78         v_sbInsert.append("INSERT INTO tblrelatedlinks ").append("(itemID, link, text, rank, linkUpdateDate)").append(
79                 " VALUES ('" + ItemID + "', '" + link + "', '" + text + "', '" + rank + "')");
80
81         execStatement(v_sbInsert.toString());
82
83         StringBuffer JavaDoc v_sbUpdate = new StringBuffer JavaDoc();
84         v_sbUpdate.append("UPDATE tblarticles").append(" SET updateDate = new() ").append(" WHERE itemID = '" + ItemID + "'");
85
86         execStatement(v_sbUpdate.toString());
87
88         execStatementToRS(queryResultOk);
89     }
90 }
91
Popular Tags