4 import java
.sql
.SQLException
;
5 import java
.sql
.ResultSetMetaData
;
11 public final class JdbcSqlResultSetMetaData
12 extends JSqlError
implements ResultSetMetaData
, JSqlErrorType
14 private boolean isClosed
;
15 JdbcSqlStatement stmt
; // This guy creates me
16 private boolean shouldDriverHandles
;
17 private FieldInfo
[] fieldMeta
;
19 JdbcSqlResultSetMetaData()
22 shouldDriverHandles
= false;
25 void setStmt( JdbcSqlStatement s
)
31 JdbcSqlResultSetMetaData(FieldInfo
[] fields
)
34 shouldDriverHandles
= true;
38 public void close() throws SQLException
45 public int getColumnCount () throws SQLException
47 if( isClosed
) throw getException( CSQL_INVALID_STATE
);
48 if (shouldDriverHandles
){
49 return this.fieldMeta
.length
;
51 return( stmt
.jniStmt
.getTotalProjFld() );
55 public int getColumnIndex (String name
) throws SQLException
57 if( isClosed
) throw getException( CSQL_INVALID_STATE
);
58 if(shouldDriverHandles
){
59 for ( int i
=0; i
< this.fieldMeta
.length
; i
++)
61 if(fieldMeta
[i
].getColname().equals(name
))
65 return( stmt
.jniStmt
.findColumn( name
) );//TO DO
68 public String
getColumnName (int colNum
) throws SQLException
70 if( isClosed
) throw getException( CSQL_INVALID_STATE
);
71 if(shouldDriverHandles
){
72 if(this.fieldMeta
.length
< colNum
)
75 return this.fieldMeta
[colNum
-1].getColname();
77 String name
= stmt
.jniStmt
.getProjFldName(colNum
);
80 public String
getColumnLabel (int colNum
) throws SQLException
82 return getColumnName( colNum
);
85 public boolean isReadOnly (int colNum
) throws SQLException
87 if( isClosed
) throw getException( CSQL_INVALID_STATE
);
90 public boolean isWritable (int colNum
) throws SQLException
92 if( isClosed
) throw getException( CSQL_INVALID_STATE
);
93 if(shouldDriverHandles
) {
98 public boolean isDefinitelyWritable (int colNum
) throws SQLException
100 if( isClosed
) throw getException( CSQL_INVALID_STATE
);
101 if(shouldDriverHandles
) {
108 public String
getColumnClassName(int colNum
) throws SQLException
110 if( isClosed
) throw getException( CSQL_INVALID_STATE
);
111 if(shouldDriverHandles
) {
112 return Util
.getClassName(this.fieldMeta
[colNum
-1].getCsqlType());
114 return Util
.getClassName(this.stmt
.jniStmt
.getProjFldType(colNum
));
117 public int getColumnType (int colNum
) throws SQLException
119 if( isClosed
) throw getException( CSQL_INVALID_STATE
);
120 if(shouldDriverHandles
) {
121 return Util
.getType(this.fieldMeta
[colNum
-1].getCsqlType());
123 return Util
.getType(this.stmt
.jniStmt
.getProjFldType(colNum
));
125 public String
getColumnTypeName (int colNum
) throws SQLException
127 if( isClosed
) throw getException( CSQL_INVALID_STATE
);
128 if(shouldDriverHandles
) {
129 return Util
.getTypeName(this.fieldMeta
[colNum
-1].getCsqlType());
131 return Util
.getTypeName(this.stmt
.jniStmt
.getProjFldType(colNum
));
133 public boolean isCaseSensitive (int colNum
) throws SQLException
135 if( isClosed
) throw getException( CSQL_INVALID_STATE
);
139 public int isNullable (int colNum
) throws SQLException
141 if( isClosed
) throw getException( CSQL_INVALID_STATE
);
142 if(shouldDriverHandles
) {
143 if(this.fieldMeta
[colNum
-1].isNullable())
144 return JdbcSqlResultSetMetaData
.columnNoNulls
;
146 return JdbcSqlResultSetMetaData
.columnNullable
;
149 if (this.stmt
.jniStmt
.isFldNullable(colNum
))
150 return JdbcSqlResultSetMetaData
.columnNoNulls
;
152 return JdbcSqlResultSetMetaData
.columnNullable
;
155 public String
getTableName (int colNum
) throws SQLException
157 if( isClosed
) throw getException( CSQL_INVALID_STATE
);
158 if(shouldDriverHandles
){
164 public boolean isSigned (int colNum
) throws SQLException
166 if( isClosed
) throw getException( CSQL_INVALID_STATE
);
169 public int getPrecision (int colNum
) throws SQLException
//TODO
171 if( isClosed
) throw getException( CSQL_INVALID_STATE
);
174 public int getScale (int colNum
) throws SQLException
//TODO
176 if( isClosed
) throw getException( CSQL_INVALID_STATE
);
179 public String
getSchemaName (int colNum
) throws SQLException
185 // UN-SUPPORTED API's
186 public int getColumnDisplaySize (int colNum
) throws SQLException
191 public boolean isAutoIncrement (int colNum
) throws SQLException
195 public boolean isCurrency (int colNum
) throws SQLException
199 public String
getCatalogName (int colNum
) throws SQLException
203 public boolean isSearchable (int colNum
) throws SQLException
205 if(shouldDriverHandles
) return false;
209 public boolean isWrapperFor(Class ifact
) throws SQLException
211 throw getException(CSQL_NOT_SUPPORTED
);
213 public Class
unwrap(Class iface
) throws SQLException
215 throw getException(CSQL_NOT_SUPPORTED
);