KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > bluecubs > xinco > core > server > XincoCoreDataTypeServer


1 /**
2  *Copyright 2004 blueCubs.com
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  *************************************************************
17  * This project supports the blueCubs vision of giving back
18  * to the community in exchange for free software!
19  * More information on: http://www.bluecubs.org
20  *************************************************************
21  *
22  * Name: XincoCoreDataTypeServer
23  *
24  * Description: data type
25  *
26  * Original Author: Alexander Manes
27  * Date: 2004
28  *
29  * Modifications:
30  *
31  * Who? When? What?
32  * - - -
33  *
34  *************************************************************
35  */

36
37 package com.bluecubs.xinco.core.server;
38
39 import java.util.Vector JavaDoc;
40 import java.sql.*;
41
42 import com.bluecubs.xinco.core.*;
43
44 public class XincoCoreDataTypeServer extends XincoCoreDataType {
45     
46     //create data type object for data structures
47
public XincoCoreDataTypeServer(int attrID, XincoDBManager DBM) throws XincoException {
48         
49         try {
50             Statement stmt = DBM.con.createStatement();
51             ResultSet rs = stmt.executeQuery("SELECT * FROM xinco_core_data_type WHERE id=" + attrID);
52
53             //throw exception if no result found
54
int RowCount = 0;
55             while (rs.next()) {
56                 RowCount++;
57                 setId(rs.getInt("id"));
58                 setDesignation(rs.getString("designation"));
59                 setDescription(rs.getString("description"));
60                 setXinco_core_data_type_attributes(XincoCoreDataTypeAttributeServer.getXincoCoreDataTypeAttributes(getId(), DBM));
61             }
62             if (RowCount < 1) {
63                 throw new XincoException();
64             }
65
66             stmt.close();
67         } catch (Exception JavaDoc e) {
68             throw new XincoException();
69         }
70         
71     }
72
73     //create data type object for data structures
74
public XincoCoreDataTypeServer(int attrID, String JavaDoc attrD, String JavaDoc attrDESC, Vector JavaDoc attrA) throws XincoException {
75         
76         setId(attrID);
77         setDesignation(attrD);
78         setDescription(attrDESC);
79         setXinco_core_data_type_attributes(attrA);
80         
81     }
82     
83     //create complete list of data types
84
public static Vector JavaDoc getXincoCoreDataTypes(XincoDBManager DBM) {
85         
86         Vector JavaDoc coreDataTypes = new Vector JavaDoc();
87         
88         try {
89             Statement stmt = DBM.con.createStatement();
90             ResultSet rs = stmt.executeQuery("SELECT * FROM xinco_core_data_type ORDER BY designation");
91
92             while (rs.next()) {
93                 coreDataTypes.addElement(new XincoCoreDataTypeServer(rs.getInt("id"), rs.getString("designation"), rs.getString("description"), XincoCoreDataTypeAttributeServer.getXincoCoreDataTypeAttributes(rs.getInt("id"), DBM)));
94             }
95
96             stmt.close();
97         } catch (Exception JavaDoc e) {
98             coreDataTypes.removeAllElements();
99         }
100
101         return coreDataTypes;
102     }
103
104 }
105
Popular Tags