FileDocCategorySizeDatePackage
MsqlResultSetMetaData.javaAPI DocExample5115Tue Jan 01 00:00:00 GMT 1980COM.imaginary.sql.msql

MsqlResultSetMetaData

public class MsqlResultSetMetaData extends Object implements ResultSetMetaData, Runnable
The MsqlResultSetMetaData class is the mSQL implementation of the JDBC ResultSetMetaData interface. It should never be referenced directly. You should instead use the JDBC API.
Last modified %D%
version
%A%
author
George Reese (borg@imaginary.com)

Fields Summary
private Vector
columns
private boolean
complete
private MsqlResultSet
field_results
private SQLException
load_exception
private String
schema
Constructors Summary
MsqlResultSetMetaData(MsqlResultSet f)

    
      
	super();
	field_results = f;
	(new Thread(this)).start();
    
Methods Summary
public java.lang.StringgetCatalogName(int column)

	throw new SQLException("mSQL does not support catalogs.");
    
MsqlColumngetColumn(int column)

	waitOnLoad();
	if( column < 1 || column > columns.size() ) {
	    throw new SQLException("Invalid column check.");
	}
	return (MsqlColumn)columns.elementAt(column-1);
    
public intgetColumnCount()

	waitOnLoad();
	return columns.size();
    
public intgetColumnDisplaySize(int column)

	MsqlColumn c = getColumn(column);

	return c.getLength();
    
public java.lang.StringgetColumnLabel(int column)

	MsqlColumn c = getColumn(column);
	
	return (c.getTableName() + "." + c.getColumnName());
    
public java.lang.StringgetColumnName(int column)

	MsqlColumn c = getColumn(column);

	return c.getColumnName();
    
public intgetColumnType(int column)

	MsqlColumn c = getColumn(column);

	return c.getType();
    
public java.lang.StringgetColumnTypeName(int column)

	MsqlColumn c = getColumn(column);
	
	switch( c.getType() ) {
	case Types.INTEGER:
	    return "INT";
	    
	case Types.CHAR:
	    return "CHAR";
	    
	case Types.REAL:
	    return "REAL";
	    
	default:
	    return "NULL";
	}
    
public intgetPrecision(int column)

	throw new SQLException("mSQL has no clue what the precision is.");
    
public intgetScale(int column)

	throw new SQLException("mSQL has no clue what the scale is.");
    
public java.lang.StringgetSchemaName(int column)

	return schema;
    
public java.lang.StringgetTableName(int column)

	MsqlColumn c = getColumn(column);

	return c.getTableName();
    
public booleanisAutoIncrement(int column)

 
	return false;
    
public booleanisCaseSensitive(int column)

	return true;
    
public booleanisCurrency(int column)

	return false;
    
public booleanisDefinitelyWritable(int column)

	return true;
    
public intisNullable(int column)

	MsqlColumn c = getColumn(column);
	
	if( c.isNullable() ) {
	    return ResultSetMetaData.columnNullable;
	}
	else {
	    return ResultSetMetaData.columnNoNulls;
	}
    
public booleanisReadOnly(int column)

	return false;
    
public booleanisSearchable(int column)

	return true;
    
public booleanisSigned(int column)

	return true;
    
public booleanisWritable(int column)

	return true;
    
public voidrun()

	try {
	    while( field_results.next() ) {
		String tname, cname;
		boolean nullable, pk;
		int type, length;
		
		schema =
		    field_results.getStatement().getConnection().getUser();
		tname = field_results.getString(1);
		cname = field_results.getString(2);
		type = field_results.getInt(3);
		length = field_results.getInt(4);
		try {
		    String tmp = field_results.getString(5);
		    
		    if( tmp.equals("Y") ) {
			nullable = false;
		    }
		    else {
			nullable = true;
		    }
		}
		catch( SQLException e ) {
		    nullable = true;
		}
		try {
		    String tmp = field_results.getString(6);
		    
		    if( tmp.equals("Y") ) {
			pk = true;
		    }
		    else {
			pk = false;
		    }
		}
		catch( SQLException e ) {
		    pk = false;
		}
		columns.addElement(new MsqlColumn(cname, tname, type,
						  length, nullable, pk));
	    }
	    synchronized( columns ) {
		complete = true;
		columns.notify();
	    }
	}
	catch( SQLException e ) {
	    synchronized( columns ) {
		load_exception = e;
		complete = true;
		columns.notify();
	    }
	}
    
private voidwaitOnLoad()

	synchronized( columns ) {
	    while( !complete ) {
		try {
		    columns.wait();
		}
		catch( InterruptedException e ) {
		    if( !complete ) {
			throw new MsqlException(e);
		    }
		}
		if( load_exception != null ) {
		    throw load_exception;
		}
	    }
	}