KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > teamkonzept > lib > TKDBResultInfo


1 /*
2  * $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/lib/TKDBResultInfo.java,v 1.6 2001/11/09 12:27:12 markus Exp $
3  *
4  */

5 package com.teamkonzept.lib;
6
7 import java.sql.*;
8
9 /**
10  * Die Namen der Tabellen aus dem DB-Result werden in einem Array
11  * abgelegt und die Typen
12  * @author
13  * @version
14  */

15 public class TKDBResultInfo {
16
17     public String JavaDoc colNames[] = null;
18     public int colTypes[] = null;
19     public int colCount = 0;
20
21     /**
22      * Konstruktor
23      *
24      * @param ResultSet rs, Ausfuehrung eines Querys (SQL) =>
25      * ein ResultSet-Object wurde kreiert und wird uebergeben
26      */

27     public TKDBResultInfo( ResultSet rs ) {
28         //super(); implzit!!
29
extractResultSetInfos( rs );
30     }
31     
32     /**
33      * Dies wird benoetigt fuer die column headings(JDBCD)
34      * Die Namen der Tabellen aus dem DB-Result werden in einem Array
35      * abgelegt und die Typen
36
37      *
38      * @param ResultSet rs, Ausfuehrung eines Querys (SQL) =>
39      * ein ResultSet-Object wurde kreiert und wird uebergeben (JDBCD)
40      */

41     public void extractResultSetInfos( ResultSet rs ) {
42         try {
43             ResultSetMetaData rsmd = rs.getMetaData();
44             colCount = rsmd.getColumnCount();
45             
46             if( colCount <= 0 ) return;
47             colNames = new String JavaDoc[ colCount ];
48             colTypes = new int[ colCount ];
49             for( int i=1; i<=colCount; i++ ){
50                 colNames[i-1] = rsmd.getColumnLabel(i).toUpperCase();
51                 colTypes[i-1] = rsmd.getColumnType(i);
52             }
53         }
54         catch (SQLException ex) {
55             TKDBLogger.logSQLException( ex );
56         }
57     }
58 }
59
60
Popular Tags