Package net.sourceforge.jtds.jdbc
Class TypeInfo
- java.lang.Object
-
- net.sourceforge.jtds.jdbc.TypeInfo
-
- All Implemented Interfaces:
java.lang.Comparable
public class TypeInfo extends java.lang.Object implements java.lang.ComparableRepresents an SQL data type as required bygetTypeInfo(). Provides a suitable natural ordering. This class probably shouldn't be public, but is required to be so by the tests.- Version:
- $Id: TypeInfo.java,v 1.5 2005-07-27 11:02:34 alin_sinpalean Exp $
- Author:
- David Eaves
-
-
Field Summary
Fields Modifier and Type Field Description private booleanautoIncrementprivate booleancaseSensitiveprivate java.lang.StringcreateParamsprivate intdataTypeprivate intdistanceFromJdbcTypeprivate booleanfixedPrecScaleprivate java.lang.StringliteralPrefixprivate java.lang.StringliteralSuffixprivate java.lang.StringlocalTypeNameprivate shortmaximumScaleprivate shortminimumScaleprivate intnormalizedTypeprivate shortnullable(package private) static intNUM_COLSprivate intnumPrecRadixprivate intprecisionprivate shortsearchableprivate intsqlDataTypeprivate intsqlDatetimeSubprivate java.lang.StringtypeNameprivate booleanunsigned
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private intcompare(int i1, int i2)intcompareTo(java.lang.Object o)Comparable implementation that orders by dataType, then by how closely the data type maps to the corresponding JDBC SQL type.private intdetermineDistanceFromJdbcType()Determine how close this type is to the corresponding JDBC type.booleanequals(java.lang.Object o)inthashCode()static intnormalizeDataType(int serverDataType, boolean useLOBs)Return aTypes-defined type for an SQL Server specific data type.java.lang.StringtoString()voidupdate(java.sql.ResultSet rs)
-
-
-
Field Detail
-
NUM_COLS
static final int NUM_COLS
- See Also:
- Constant Field Values
-
typeName
private final java.lang.String typeName
-
dataType
private final int dataType
-
precision
private final int precision
-
literalPrefix
private final java.lang.String literalPrefix
-
literalSuffix
private final java.lang.String literalSuffix
-
createParams
private final java.lang.String createParams
-
nullable
private final short nullable
-
caseSensitive
private final boolean caseSensitive
-
searchable
private final short searchable
-
unsigned
private final boolean unsigned
-
fixedPrecScale
private final boolean fixedPrecScale
-
autoIncrement
private final boolean autoIncrement
-
localTypeName
private final java.lang.String localTypeName
-
minimumScale
private final short minimumScale
-
maximumScale
private final short maximumScale
-
sqlDataType
private final int sqlDataType
-
sqlDatetimeSub
private final int sqlDatetimeSub
-
numPrecRadix
private final int numPrecRadix
-
normalizedType
private final int normalizedType
-
distanceFromJdbcType
private final int distanceFromJdbcType
-
-
Constructor Detail
-
TypeInfo
public TypeInfo(java.sql.ResultSet rs, boolean useLOBs) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
TypeInfo
public TypeInfo(java.lang.String typeName, int dataType, boolean autoIncrement)For testing only. Create an instance with just the properties utilised in thecompareTo()method (set name, type, and auto increment).
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
update
public void update(java.sql.ResultSet rs) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
compareTo
public int compareTo(java.lang.Object o)
Comparable implementation that orders by dataType, then by how closely the data type maps to the corresponding JDBC SQL type. The data type values for the non-standard SQL Server types tend to have negative numbers while the corresponding standard types have positive numbers so utilise that in the sorting.- Specified by:
compareToin interfacejava.lang.Comparable
-
compare
private int compare(int i1, int i2)
-
determineDistanceFromJdbcType
private int determineDistanceFromJdbcType()
Determine how close this type is to the corresponding JDBC type. Used in sorting to distinguish between types that have the samenormalizedTypevalue.- Returns:
- positive integer indicating how far away the type is from the corresponding JDBC type, with zero being the nearest possible match and 9 being the least
-
normalizeDataType
public static int normalizeDataType(int serverDataType, boolean useLOBs)Return aTypes-defined type for an SQL Server specific data type.- Parameters:
serverDataType- the data type, as returned by the serveruseLOBs- whether LOB data types are used for large types- Returns:
- the equivalent data type defined by
java.sql.Types
-
-