1 36 37 package com.bluecubs.xinco.core.server; 38 39 import java.util.Vector ; 40 import java.sql.*; 41 42 import com.bluecubs.xinco.core.*; 43 44 public class XincoCoreDataTypeServer extends XincoCoreDataType { 45 46 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 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 e) { 68 throw new XincoException(); 69 } 70 71 } 72 73 public XincoCoreDataTypeServer(int attrID, String attrD, String attrDESC, Vector attrA) throws XincoException { 75 76 setId(attrID); 77 setDesignation(attrD); 78 setDescription(attrDESC); 79 setXinco_core_data_type_attributes(attrA); 80 81 } 82 83 public static Vector getXincoCoreDataTypes(XincoDBManager DBM) { 85 86 Vector coreDataTypes = new Vector (); 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 e) { 98 coreDataTypes.removeAllElements(); 99 } 100 101 return coreDataTypes; 102 } 103 104 } 105 | Popular Tags |