|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.sourceforge.jtds.jdbc.Support
This class contains static utility methods designed to support the main driver classes.
Implementation notes:
Field Summary | |
private static java.math.BigDecimal |
BIG_DECIMAL_ONE
|
private static java.math.BigDecimal |
BIG_DECIMAL_ZERO
|
private static java.util.GregorianCalendar |
cal
Static utility Calendar object. |
private static java.sql.Date |
DATE_ZERO
|
private static java.lang.Double |
DOUBLE_ONE
|
private static java.lang.Double |
DOUBLE_ZERO
|
private static java.lang.Float |
FLOAT_ONE
|
private static java.lang.Float |
FLOAT_ZERO
|
private static char[] |
hex
Hex constants to use in conversion routines. |
private static java.lang.Integer |
INTEGER_ONE
|
private static java.lang.Integer |
INTEGER_ZERO
|
private static java.lang.Long |
LONG_ONE
|
private static java.lang.Long |
LONG_ZERO
|
private static java.math.BigInteger |
maxValue28
|
private static java.math.BigInteger |
maxValue38
|
private static java.sql.Time |
TIME_ZERO
|
private static java.util.HashMap |
typeMap
Convert java clases to java.sql.Type constant. |
Constructor Summary | |
private |
Support()
|
Method Summary | |
(package private) static void |
|
private static java.lang.String |
bigDecimalToString(java.math.BigDecimal x)
Convert a BigDecimal value to String ,
stripping any trailing zeroes. |
(package private) static java.lang.Object |
convert(java.lang.Object callerReference,
java.lang.Object x,
int jdbcType,
java.lang.String charSet)
Convert an existing data object to the specified JDBC type. |
(package private) static void |
embedData(java.lang.StringBuffer buf,
java.lang.Object value,
boolean isUnicode,
int tdsVersion)
Embed the data object as a string literal in the buffer supplied. |
(package private) static byte[] |
encodeString(java.lang.String cs,
java.lang.String value)
Encode a string into a byte array using the specified character set. |
(package private) static java.lang.String |
getClassName(int jdbcType)
Retrieve the fully qualified java class name for the supplied JDBC Types constant. |
static ConnectionJDBC2 |
getConnection(java.lang.Object callerReference)
Returns the connection for a given ResultSet ,
Statement or Connection object. |
(package private) static int |
getJdbcType(java.lang.Object value)
Get the JDBC type constant which matches the supplied Object type. |
(package private) static java.lang.String |
getJdbcTypeName(int jdbcType)
Get a String describing the supplied JDBC type constant. |
(package private) static java.lang.String |
getParameterDefinitions(ParamInfo[] parameters)
Constructs a parameter definition string for use with sp_executesql, sp_prepare, sp_prepexec, sp_cursoropen, sp_cursorprepare and sp_cursorprepexec. |
(package private) static java.lang.String |
getStatementKey(java.lang.String sql,
ParamInfo[] params,
int serverType,
java.lang.String catalog)
Generates a unique statement key for a given SQL statement. |
static java.sql.SQLException |
linkException(java.sql.SQLException sqle,
java.lang.Throwable cause)
Link an the original cause exception to a SQL Exception. |
(package private) static java.math.BigDecimal |
normalizeBigDecimal(java.math.BigDecimal value,
int maxPrecision)
Normalize a BigDecimal value so that it fits within the available precision. |
(package private) static java.lang.String |
substituteParameters(java.lang.String sql,
ParamInfo[] list,
int tdsVersion)
Substitute actual data for the parameter markers to simulate parameter substitution in a PreparedStatement. |
(package private) static java.lang.String |
substituteParamMarkers(java.lang.String sql,
ParamInfo[] list)
Update the SQL string and replace the ? markers with parameter names eg @P0, @P1 etc. |
static long |
timeFromZone(java.util.Date value,
java.util.Calendar target)
Convert a timestamp from a different Timezone. |
static long |
timeToZone(java.util.Date value,
java.util.Calendar target)
Convert a timestamp to a different Timezone. |
static java.lang.String |
toHex(byte[] bytes)
Convert a byte[] object to a hex string. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
Field Detail |
private static final java.lang.Integer INTEGER_ZERO
private static final java.lang.Integer INTEGER_ONE
private static final java.lang.Long LONG_ZERO
private static final java.lang.Long LONG_ONE
private static final java.lang.Float FLOAT_ZERO
private static final java.lang.Float FLOAT_ONE
private static final java.lang.Double DOUBLE_ZERO
private static final java.lang.Double DOUBLE_ONE
private static final java.math.BigDecimal BIG_DECIMAL_ZERO
private static final java.math.BigDecimal BIG_DECIMAL_ONE
private static final java.sql.Date DATE_ZERO
private static final java.sql.Time TIME_ZERO
private static final java.math.BigInteger maxValue28
private static final java.math.BigInteger maxValue38
private static final java.util.HashMap typeMap
private static final char[] hex
private static final java.util.GregorianCalendar cal
Constructor Detail |
private Support()
Method Detail |
static void()
public static java.lang.String toHex(byte[] bytes)
bytes
- The byte array to convert.String
.static java.math.BigDecimal normalizeBigDecimal(java.math.BigDecimal value, int maxPrecision) throws java.sql.SQLException
value
- The decimal value to normalize.maxPrecision
- The decimal precision supported by the server
(assumed to be a value of either 28 or 38).BigDecimal
.java.sql.SQLException
- If the number is too big.private static java.lang.String bigDecimalToString(java.math.BigDecimal x)
BigDecimal
value to String
,
stripping any trailing zeroes.x
- the BigDecimal
value to convertString
static java.lang.Object convert(java.lang.Object callerReference, java.lang.Object x, int jdbcType, java.lang.String charSet) throws java.sql.SQLException
callerReference
- an object reference to the caller of this method;
must be a Connection
,
Statement
or ResultSet
x
- the data object to convertjdbcType
- the required type constant from
java.sql.Types
java.sql.SQLException
- if the conversion is not supported or failsstatic int getJdbcType(java.lang.Object value)
value
- The object to analyse.int
.static java.lang.String getJdbcTypeName(int jdbcType)
jdbcType
- The constant to be decoded.String
.static java.lang.String getClassName(int jdbcType)
jdbcType
- The JDBC Types constant.String
.static void embedData(java.lang.StringBuffer buf, java.lang.Object value, boolean isUnicode, int tdsVersion) throws java.sql.SQLException
buf
- The buffer in which the data will be embeded.value
- The data object.static java.lang.String getStatementKey(java.lang.String sql, ParamInfo[] params, int serverType, java.lang.String catalog)
sql
- the sql statment to generate the key forparams
- the statement parametersserverType
- the type of server to generate the key forcatalog
- the catalog is required for uniqueness on Microsoft SQL Serverstatic java.lang.String getParameterDefinitions(ParamInfo[] parameters)
parameters
- Parameters to construct the definition forstatic java.lang.String substituteParamMarkers(java.lang.String sql, ParamInfo[] list)
sql
- the SQL containing markers to substitutelist
- the parameter listString
static java.lang.String substituteParameters(java.lang.String sql, ParamInfo[] list, int tdsVersion) throws java.sql.SQLException
sql
- The SQL containing parameter markers to substitute.list
- The parameter descriptors.static byte[] encodeString(java.lang.String cs, java.lang.String value)
cs
- The Charset name.value
- The value to encode.byte[]
.public static java.sql.SQLException linkException(java.sql.SQLException sqle, java.lang.Throwable cause)
If running under VM 1.4+ the Exception.initCause() method will be used to chain the exception. Modeled after the code written by Brian Heineman.
sqle
- The SQLException to enhance.cause
- The child exception to link.SQLException
.public static long timeToZone(java.util.Date value, java.util.Calendar target)
value
- the timestamp valuetarget
- the Calendar
containing the TimeZonelong
public static long timeFromZone(java.util.Date value, java.util.Calendar target)
value
- the timestamp value.target
- the Calendar containing the TimeZone.long
.public static ConnectionJDBC2 getConnection(java.lang.Object callerReference)
ResultSet
,
Statement
or Connection
object.callerReference
- an object reference to the caller of this method;
must be a Connection
, Statement
or
ResultSet
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |