1 5 package com.teamkonzept.lib; 6 7 import java.sql.*; 8 import java.util.*; 9 10 26 public class TKDBResultRowHash extends TKHashtable implements TKDBResultRow { 27 28 protected boolean hasResult = false; 29 31 protected Vector colNames = null; 33 35 42 public TKDBResultRowHash( ResultSet rs ) 43 { 44 this( rs, new TKDBResultInfo( rs ) ); 45 } 46 47 55 public TKDBResultRowHash( ResultSet rs, TKDBResultInfo info ) 56 { 57 super( info.colCount ); 58 60 this.colNames = new Vector(); 62 for (int i = 0 ; i < info.colNames.length ; i++) 63 { 64 this.colNames.addElement(info.colNames[i]); 65 } 66 68 getResult( rs, info ); 69 } 70 80 public boolean getResult( ResultSet rs, TKDBResultInfo info ) 81 { 82 try { 83 if( !rs.next() ) return false; 84 for (int i=1; i<=info.colCount; i++) { 85 put( info.colNames[i-1], TKDBObjectCreator.getResultObject( rs, i, info.colTypes[i-1] ) ); 86 } 87 hasResult = true; 88 return true; 89 } 90 catch (SQLException ex) { 91 TKDBLogger.logSQLException( ex ); 92 } 93 return false; 94 } 95 96 100 public final boolean hasResult() 101 { 102 return hasResult; 103 } 104 105 109 public Object getColumn( String colName ) 110 { 111 return get( colName ); 112 } 113 114 119 public Object getColumn( int colIdx ) 120 { 121 123 return get( colNames.elementAt(colIdx) ); 125 } 127 128 132 public String getColumnLabel( int colIdx ) 133 { 134 136 return (String ) colNames.elementAt(colIdx); 138 } 140 141 145 public int getColumnCount() 146 { 147 149 return colNames.size(); 151 } 153 154 158 public void addColumn(String name, Object value) 159 { 160 colNames.addElement(name); 161 put (name, value); 162 } 163 } 164 165 | Popular Tags |