ControllerResultSet
is a lightweight ResultSet for the controller side. It only contains row data and column metadata. The real ResultSet is constructed on by the driver on the client side from the ControllerResultSet information.
ControllerResultSet.java の 47 行で定義されています。
Public メソッド | |
ControllerResultSet (AbstractRequest request, java.sql.ResultSet rs, MetadataCache metadataCache) throws SQLException | |
ArrayList | fetchData () throws SQLException |
ArrayList | getData () |
Field[] | getFields () |
String | getCursorName () |
boolean | hasMoreData () |
void | closeResultSet () |
Private 変数 | |
ArrayList | data = null |
Field[] | fields = null |
String | cursorName = null |
int | fetchSize = 0 |
ResultSet | dbResultSet = null |
boolean | dbResultSetClosed = true |
boolean | hasMoreData = false |
int | maxRows = 0 |
|
Build a C-JDBC ResultSet from a database specific ResultSet. The metadata can be retrieved from the MetadataCache if provided. If a metadata cache is provided but the data is not in the cache, the MetadataCache is updated accordingly. The remaining code is a straightforward copy of both metadata and data.
ControllerResultSet.java の 78 行で定義されています。 参照先 org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet.dbResultSet, org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet.dbResultSetClosed, org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet.fetchData(), org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet.fields, org.objectweb.cjdbc.common.sql.SelectRequest.getCursorName(), org.objectweb.cjdbc.common.sql.SelectRequest.getFetchSize(), と org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet.hasMoreData.
00080 { 00081 try 00082 { 00083 if (rs == null) 00084 throw new SQLException("Null ResultSet"); 00085 00086 // This is already a result coming from another controller. 00087 //if (rs instanceof org.objectweb.cjdbc.driver.ResultSet) 00088 // return (org.objectweb.cjdbc.driver.ResultSet) rs; 00089 00090 // Build the ResultSet metaData 00091 int nbColumn; 00092 if (metadataCache != null) 00093 fields = metadataCache.getMetadata(request); 00094 00095 if (fields == null) 00096 { // Metadata Cache miss 00097 // Build the fields from the MetaData 00098 java.sql.ResultSetMetaData metaData = rs.getMetaData(); 00099 if (metaData == null) 00100 throw new SQLException("unable to fetch metadata"); 00101 nbColumn = metaData.getColumnCount(); 00102 fields = new Field[nbColumn]; 00103 for (int i = 0; i < nbColumn; i++) 00104 { 00105 // 1st column is 1 00106 String columnName = metaData.getColumnName(i + 1); 00107 if (metadataCache != null) 00108 { // Check Field cache 00109 fields[i] = metadataCache.getField(columnName); 00110 if (fields[i] != null) 00111 continue; // Cache hit 00112 } 00113 // Field cache miss 00114 String tableName = null; 00115 try 00116 { 00117 tableName = metaData.getTableName(i + 1); 00118 } 00119 catch (Exception ignore) 00120 { 00121 } 00122 int columnDisplaySize = 0; 00123 try 00124 { 00125 columnDisplaySize = metaData.getColumnDisplaySize(i + 1); 00126 } 00127 catch (Exception ignore) 00128 { 00129 } 00130 int columnType = -1; 00131 try 00132 { 00133 columnType = metaData.getColumnType(i + 1); 00134 } 00135 catch (Exception ignore) 00136 { 00137 } 00138 String columnTypeName = null; 00139 try 00140 { 00141 columnTypeName = metaData.getColumnTypeName(i + 1); 00142 } 00143 catch (Exception ignore) 00144 { 00145 } 00146 String columnClassName = null; 00147 try 00148 { 00149 columnClassName = metaData.getColumnClassName(i + 1); 00150 } 00151 catch (Exception ignore) 00152 { 00153 } 00154 boolean isAutoIncrement = false; 00155 try 00156 { 00157 isAutoIncrement = metaData.isAutoIncrement(i + 1); 00158 } 00159 catch (Exception ignore) 00160 { 00161 } 00162 boolean isCaseSensitive = false; 00163 try 00164 { 00165 isCaseSensitive = metaData.isCaseSensitive(i + 1); 00166 } 00167 catch (Exception ignore) 00168 { 00169 } 00170 boolean isCurrency = false; 00171 try 00172 { 00173 isCurrency = metaData.isCurrency(i + 1); 00174 } 00175 catch (Exception ignore) 00176 { 00177 } 00178 int isNullable = ResultSetMetaData.columnNullableUnknown; 00179 try 00180 { 00181 isNullable = metaData.isNullable(i + 1); 00182 } 00183 catch (Exception ignore) 00184 { 00185 } 00186 boolean isReadOnly = false; 00187 try 00188 { 00189 isReadOnly = metaData.isReadOnly(i + 1); 00190 } 00191 catch (Exception ignore) 00192 { 00193 } 00194 boolean isWritable = false; 00195 try 00196 { 00197 isWritable = metaData.isWritable(i + 1); 00198 } 00199 catch (Exception ignore) 00200 { 00201 } 00202 boolean isDefinitelyWritable = false; 00203 try 00204 { 00205 isReadOnly = metaData.isDefinitelyWritable(i + 1); 00206 } 00207 catch (Exception ignore) 00208 { 00209 } 00210 boolean isSearchable = false; 00211 try 00212 { 00213 isSearchable = metaData.isSearchable(i + 1); 00214 } 00215 catch (Exception ignore) 00216 { 00217 } 00218 boolean isSigned = false; 00219 try 00220 { 00221 isSigned = metaData.isSigned(i + 1); 00222 } 00223 catch (Exception ignore) 00224 { 00225 } 00226 int precision = 0; 00227 try 00228 { 00229 precision = metaData.getPrecision(i + 1); 00230 } 00231 catch (Exception ignore) 00232 { 00233 } 00234 int scale = 0; 00235 try 00236 { 00237 scale = metaData.getScale(i + 1); 00238 } 00239 catch (Exception ignore) 00240 { 00241 } 00242 fields[i] = new Field(tableName, columnName, columnDisplaySize, 00243 columnType, columnTypeName, columnClassName, isAutoIncrement, 00244 isCaseSensitive, isCurrency, isNullable, isReadOnly, isWritable, 00245 isDefinitelyWritable, isSearchable, isSigned, precision, scale); 00246 00247 if (metadataCache != null) 00248 // Add field to cache 00249 metadataCache.addField(columnName, fields[i]); 00250 } 00251 } 00252 else 00253 nbColumn = fields.length; 00254 00255 // Build the ResultSet data 00256 if (rs.next()) 00257 { 00258 if (request instanceof SelectRequest) 00259 { 00260 SelectRequest select = (SelectRequest) request; 00261 cursorName = select.getCursorName(); 00262 fetchSize = select.getFetchSize(); 00263 } 00264 maxRows = request.getMaxRows(); 00265 if (maxRows == 0) 00266 maxRows = Integer.MAX_VALUE; // Infinite number of rows 00267 00268 // Note that fetchData updates the data field 00269 dbResultSet = rs; 00270 fetchData(); 00271 if (hasMoreData && (cursorName == null)) 00272 cursorName = String.valueOf(dbResultSet.hashCode()); 00273 } 00274 else 00275 { 00276 hasMoreData = false; 00277 dbResultSet = null; 00278 dbResultSetClosed = true; 00279 rs.close(); 00280 } 00281 } 00282 catch (SQLException e) 00283 { 00284 throw new SQLException("Error while building C-JDBC ResultSet (" + e 00285 + ")"); 00286 } 00287 } |
|
Closes the database ResultSet to release the resource and garbage collect data. ControllerResultSet.java の 384 行で定義されています。 参照先 org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet.dbResultSet, と org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet.dbResultSetClosed. 参照元 org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabaseWorkerThread.run().
00385 { 00386 if ((dbResultSet != null) && !dbResultSetClosed) 00387 { 00388 try 00389 { 00390 dbResultSet.close(); 00391 } 00392 catch (SQLException ignore) 00393 { 00394 } 00395 dbResultSet = null; // to allow GC to work properly 00396 } 00397 } |
|
Fetch the next rows of data from dbResultSet according to fetchSize and maxRows parameters. This methods directly updates the data and hasMoreData fields and returns the same Object as subsequent calls to getData().
ControllerResultSet.java の 298 行で定義されています。 参照先 org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet.dbResultSet, org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet.dbResultSetClosed, org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet.fields, と org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet.hasMoreData. 参照元 org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet.ControllerResultSet(), と org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabaseWorkerThread.run().
00299 { 00300 if (dbResultSet == null) 00301 return null; 00302 00303 Object[] row; 00304 // We directly update the data field 00305 data = new ArrayList(); 00306 int toFetch; 00307 if (fetchSize > 0) 00308 { 00309 toFetch = fetchSize < maxRows ? fetchSize : maxRows; 00310 maxRows -= toFetch; 00311 } 00312 else 00313 toFetch = maxRows; 00314 int nbColumn = fields.length; 00315 do 00316 { 00317 row = new Object[nbColumn]; 00318 for (int i = 0; i < nbColumn; i++) 00319 row[i] = dbResultSet.getObject(i + 1); 00320 data.add(row); 00321 toFetch--; 00322 hasMoreData = dbResultSet.next(); 00323 } 00324 while (hasMoreData && (toFetch > 0)); 00325 if (hasMoreData && (fetchSize > 0) && (maxRows > 0)) 00326 { // More data to fetch later on 00327 maxRows += toFetch; 00328 dbResultSetClosed = false; 00329 } 00330 else 00331 { 00332 hasMoreData = false; 00333 dbResultSet.close(); 00334 dbResultSet = null; 00335 dbResultSetClosed = true; 00336 } 00337 return data; 00338 } |
|
Get the name of the SQL cursor used by this ResultSet
ControllerResultSet.java の 365 行で定義されています。 参照元 org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabaseWorkerThread.run().
00366 { 00367 return cursorName; 00368 } |
|
Returns the data value.
ControllerResultSet.java の 345 行で定義されています。 参照元 org.objectweb.cjdbc.controller.cache.result.ResultCache.needInvalidate(), と org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabaseWorkerThread.run().
00346 { 00347 return data; 00348 } |
|
Returns the fields value.
ControllerResultSet.java の 355 行で定義されています。 参照先 org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet.fields. 参照元 org.objectweb.cjdbc.controller.cache.result.ResultCache.needInvalidate(), と org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabaseWorkerThread.run().
00356 { 00357 return fields; 00358 } |
|
Returns the hasMoreData value.
ControllerResultSet.java の 375 行で定義されています。
00376 { 00377 return hasMoreData; 00378 } |
|
Cursor name for this ResultSet (not used yet) ControllerResultSet.java の 54 行で定義されています。 |
|
The results ControllerResultSet.java の 50 行で定義されています。 |
|
Database ResultSet if we need to fetch data later on ControllerResultSet.java の 58 行で定義されています。 参照元 org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet.closeResultSet(), org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet.ControllerResultSet(), と org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet.fetchData(). |
|
True if the underlying database ResultSet is closed ControllerResultSet.java の 60 行で定義されています。 参照元 org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet.closeResultSet(), org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet.ControllerResultSet(), と org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet.fetchData(). |
|
Fetch size if we need to fetch only a subset of the ResultSet ControllerResultSet.java の 56 行で定義されています。 |
|
|
True if there is still more data to fetch from dbResultSet ControllerResultSet.java の 62 行で定義されています。 参照元 org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet.ControllerResultSet(), org.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet.fetchData(), と org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabaseWorkerThread.run(). |
|
Maximum number of rows remaining to fetch ControllerResultSet.java の 64 行で定義されています。 |