/**
* 取得当前连接数据库指定表的字段信息。
* @param tableName 表名称
* @return 字段信息列表
* @exception SQLException Description of the Exception
* @throws Exception 失败时抛出
*/
public ParameterList getFieldList( String tableName )
throws SQLException
{
ResultSet rs = executeQuery( "SELECT * FROM " + tableName );
ResultSetMetaData meta = rs.getMetaData( );
int columnCount = meta.getColumnCount( );
ParameterList result = new ParameterList( ); for ( int i = 0; i < columnCount; i++ )
{
DBTableFieldStruct field = new DBTableFieldStruct( );
int cursor = i + 1;
field.name = meta.getColumnName( cursor );
field.type = meta.getColumnType( cursor );
field.size = meta.getColumnDisplaySize( cursor );
field.scale = meta.getScale( cursor );
field.isNullable = meta.isNullable( cursor ); //field.precision = meta.getPrecision( cursor );
result.append( field );
} return result;
}
* 取得当前连接数据库指定表的字段信息。
* @param tableName 表名称
* @return 字段信息列表
* @exception SQLException Description of the Exception
* @throws Exception 失败时抛出
*/
public ParameterList getFieldList( String tableName )
throws SQLException
{
ResultSet rs = executeQuery( "SELECT * FROM " + tableName );
ResultSetMetaData meta = rs.getMetaData( );
int columnCount = meta.getColumnCount( );
ParameterList result = new ParameterList( ); for ( int i = 0; i < columnCount; i++ )
{
DBTableFieldStruct field = new DBTableFieldStruct( );
int cursor = i + 1;
field.name = meta.getColumnName( cursor );
field.type = meta.getColumnType( cursor );
field.size = meta.getColumnDisplaySize( cursor );
field.scale = meta.getScale( cursor );
field.isNullable = meta.isNullable( cursor ); //field.precision = meta.getPrecision( cursor );
result.append( field );
} return result;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货