poolmanresultsetmetadata.java
来自「Java Database connection pool」· Java 代码 · 共 248 行
JAVA
248 行
package com.codestudio.sql;/* * An addition to the PoolMan Java Object Pooling and Caching Library * Copyright (C) 1999-2001 The Code Studio * * This file was contrbuted by and is * Copyright (C) 2001 HotMagna, http://www.hotmagna.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * The full license is located at the root of this distribution * in the LICENSE file. *//** PoolManResultSetMetaData takes a copy of a java.sql.ResultSetMetaData * for later usage. Some databases use the underlying ResultSet for * ResultSetMetaData information, so closing the ResultSet makes the * ResultSetMetaData unavailable. Given a database-specific ResultSetMetaData * object, this class creates a copy of the values and makes them available * long after the ResultSet has been closed. * * This class is used by PoolManStatement and is stored in the cache. * */public class PoolManResultSetMetaData implements java.sql.ResultSetMetaData, java.io.Serializable { private int _columnCount; private String[] _columnTypeName; private String[] _columnClassName; private int[] _scale; private String[] _columnLabel; private boolean[] _autoIncrement; private int[] _columnDisplaySize; private String[] _catalogName; private String[] _columnName; private boolean[] _writable; private boolean[] _searchable; private int[] _columnType; private boolean[] _currency; private String[] _tableName; private int[] _nullable; private boolean[] _signed; private boolean[] _readOnly; private boolean[] _definitelyWritable; private int[] _precision; private String[] _schemaName; private boolean[] _caseSensitive; // used for storing error information from when getColumnClassName() fails private String _sqlReason; private String _sqlState; private int _sqlVendorCode; public static java.sql.ResultSetMetaData getCopy(java.sql.ResultSetMetaData original) throws java.sql.SQLException { if (original instanceof PoolManResultSetMetaData) return original; else return new PoolManResultSetMetaData(original); } private PoolManResultSetMetaData(java.sql.ResultSetMetaData other) throws java.sql.SQLException { _columnCount = other.getColumnCount(); _columnTypeName = new String[_columnCount]; _columnClassName = new String[_columnCount]; _scale = new int[_columnCount]; _columnLabel = new String[_columnCount]; _autoIncrement = new boolean[_columnCount]; _columnDisplaySize = new int[_columnCount]; _catalogName = new String[_columnCount]; _columnName = new String[_columnCount]; _writable = new boolean[_columnCount]; _searchable = new boolean[_columnCount]; _columnType = new int[_columnCount]; _currency = new boolean[_columnCount]; _tableName = new String[_columnCount]; _nullable = new int[_columnCount]; _signed = new boolean[_columnCount]; _readOnly = new boolean[_columnCount]; _definitelyWritable = new boolean[_columnCount]; _precision = new int[_columnCount]; _schemaName = new String[_columnCount]; _caseSensitive = new boolean[_columnCount]; for (int c = 0; c < _columnCount; c++) { _columnTypeName[c] = other.getColumnTypeName(c + 1); if (_columnClassName != null) { // this only works on JDBC compliant drivers try { _columnClassName[c] = other.getColumnClassName(c + 1); } catch (java.sql.SQLException x) { _columnClassName = null; // don't try again! _sqlReason = x.getMessage(); _sqlState = x.getSQLState(); _sqlVendorCode = x.getErrorCode(); } catch (Throwable e) { _columnClassName = null; // don't try again! } } _scale[c] = other.getScale(c + 1); _columnLabel[c] = other.getColumnLabel(c + 1); _autoIncrement[c] = other.isAutoIncrement(c + 1); _columnDisplaySize[c] = other.getColumnDisplaySize(c + 1); try { _catalogName[c] = other.getCatalogName(c + 1); } catch (Exception e) { } if (_catalogName[c] == null) _catalogName[c] = ""; _columnName[c] = other.getColumnName(c + 1); _writable[c] = other.isWritable(c + 1); _searchable[c] = other.isSearchable(c + 1); _columnType[c] = other.getColumnType(c + 1); _currency[c] = other.isCurrency(c + 1); try { _tableName[c] = other.getTableName(c + 1); } catch (Exception e) { } if (_tableName[c] == null) _tableName[c] = ""; _nullable[c] = other.isNullable(c + 1); _signed[c] = other.isSigned(c + 1); _readOnly[c] = other.isReadOnly(c + 1); _definitelyWritable[c] = other.isDefinitelyWritable(c + 1); _precision[c] = other.getPrecision(c + 1); try { _schemaName[c] = other.getSchemaName(c + 1); } catch (Exception e) { } if (_schemaName[c] == null) _schemaName[c] = ""; _caseSensitive[c] = other.isCaseSensitive(c + 1); } } public int getColumnCount() throws java.sql.SQLException { return _columnCount; } public java.lang.String getColumnTypeName(int column) throws java.sql.SQLException { return _columnTypeName[column - 1]; } public java.lang.String getColumnClassName(int column) throws java.sql.SQLException { if (_columnClassName == null) { // java.sql.ResultSetMetaData.getColumnClassName(int col) requires a JDBC 2 compliant database driver. throw new java.sql.SQLException(_sqlReason, _sqlState, _sqlVendorCode); } return _columnClassName[column - 1]; } public int getScale(int column) throws java.sql.SQLException { return _scale[column - 1]; } public java.lang.String getColumnLabel(int column) throws java.sql.SQLException { return _columnLabel[column - 1]; } public boolean isAutoIncrement(int column) throws java.sql.SQLException { return _autoIncrement[column - 1]; } public int getColumnDisplaySize(int column) throws java.sql.SQLException { return _columnDisplaySize[column - 1]; } public java.lang.String getCatalogName(int column) throws java.sql.SQLException { return _catalogName[column - 1]; } public java.lang.String getColumnName(int column) throws java.sql.SQLException { return _columnName[column - 1]; } public boolean isWritable(int column) throws java.sql.SQLException { return _writable[column - 1]; } public boolean isSearchable(int column) throws java.sql.SQLException { return _searchable[column - 1]; } public int getColumnType(int column) throws java.sql.SQLException { return _columnType[column - 1]; } public boolean isCurrency(int column) throws java.sql.SQLException { return _currency[column - 1]; } public java.lang.String getTableName(int column) throws java.sql.SQLException { return _tableName[column - 1]; } public int isNullable(int column) throws java.sql.SQLException { return _nullable[column - 1]; } public boolean isSigned(int column) throws java.sql.SQLException { return _signed[column - 1]; } public boolean isReadOnly(int column) throws java.sql.SQLException { return _readOnly[column - 1]; } public boolean isDefinitelyWritable(int column) throws java.sql.SQLException { return _definitelyWritable[column - 1]; } public int getPrecision(int column) throws java.sql.SQLException { return _precision[column - 1]; } public java.lang.String getSchemaName(int column) throws java.sql.SQLException { return _schemaName[column - 1]; } public boolean isCaseSensitive(int column) throws java.sql.SQLException { return _caseSensitive[column - 1]; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?