1 5 package com.teamkonzept.lib; 6 7 import java.sql.*; 8 9 13 public class TKDBResultRowList extends TKVector implements TKDBResultRow { 14 15 protected boolean hasResult = false; 16 protected String colNames[] = null; 17 18 22 public TKDBResultRowList( ResultSet rs ) 23 { 24 this( rs, new TKDBResultInfo( rs ) ); 25 } 26 27 public TKDBResultRowList( ResultSet rs, TKDBResultInfo info ) 28 { 29 super( info.colCount ); 30 this.colNames = info.colNames; 31 getResult( rs, info ); 32 } 33 34 public boolean getResult( ResultSet rs, TKDBResultInfo info ) 35 { 36 try { 37 if( !rs.next() ) return false; 38 for (int i=1; i<=info.colCount; i++) { 39 addElement( TKDBObjectCreator.getResultObject( rs, i, info.colTypes[i-1] ) ); 40 } 41 hasResult = true; 42 return true; 43 } 44 catch (SQLException ex) { 45 TKDBLogger.logSQLException( ex ); 46 } 47 return false; 48 } 49 50 public final boolean hasResult() 51 { 52 return hasResult; 53 } 54 55 public Object getColumn( String colName ) 56 { 57 for( int i=0; i<colNames.length; i++ ) { 58 if( colName.equals( colNames[i] ) ){ 59 return get( i ); 60 } 61 } 62 return null; 63 } 64 65 public Object getColumn( int colIdx ) 66 { 67 return get( colIdx ); 68 } 69 70 public String getColumnLabel( int colIdx ) 71 { 72 return colNames[ colIdx ]; 73 } 74 75 public int getColumnCount() 76 { 77 return colNames.length; 78 } 79 80 } 81 82 | Popular Tags |