KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > smile > stored > s_editGroupType


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

17 public class s_editGroupType extends StoredProcedure implements ProcedureInterface {
18
19     // proprietes propres a cette stored proc
20
String JavaDoc in_grouptypeID;
21
22     String JavaDoc in_groupTypeName;
23
24     String JavaDoc in_groupTypeDesc;
25
26     String JavaDoc in_newgrouptypeid;
27
28     public s_editGroupType() {
29     }
30
31     public void init(HashMap initData, Connection con) {
32         // on initialise le hashmap de donnees et la connection de l'objet
33
super.init(initData, con);
34         // on initialise les propprietes de l'objet
35
in_grouptypeID = utils.getString(data, "GROUPTYPEID", "");
36         in_groupTypeName = utils.getString(data, "GROUPTYPENAME", "");
37         in_groupTypeDesc = utils.getString(data, "GROUPTYPEDESC", "");
38     }
39
40     public void checkParams() throws SQLException {
41     }
42
43     public void checkAction() throws SQLException {
44         if (in_grouptypeID.equals("0")) {
45             action = "insert";
46         } else {
47             action = "update";
48         }
49     }
50
51     public void executeAction() throws SQLException {
52         String JavaDoc v_select = "select 1 as returnValue";
53         if (action.equals("update")) {
54             StringBuffer JavaDoc v_sb = new StringBuffer JavaDoc();
55             v_sb.append("UPDATE tblpermgrouptype ").append(" SET grouptypename = '" + in_groupTypeName + "',").append(
56                     " grouptypedesc = '" + in_groupTypeDesc + "'").append(" WHERE grouptypeid = " + in_grouptypeID);
57
58             execStatement(v_sb.toString());
59         } else if (action.equals("insert")) {
60             StringBuffer JavaDoc v_sb = new StringBuffer JavaDoc();
61             v_sb.append("INSERT INTO tblpermgrouptype ").append("(grouptypename, grouptypedesc)").append(
62                     " VALUES ('" + in_groupTypeName + "', '" + in_groupTypeDesc + "')");
63
64             execStatement(v_sb.toString());
65         }
66         execStatementToRS(v_select);
67     }
68 }
Popular Tags