Java Doc for Support.java in  » Database-JDBC-Connection-Pool » jTDS » net » sourceforge » jtds » jdbc » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database JDBC Connection Pool » jTDS » net.sourceforge.jtds.jdbc 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   net.sourceforge.jtds.jdbc.Support

Support
public class Support (Code)
This class contains static utility methods designed to support the main driver classes.

Implementation notes:

  1. The methods in this class incorporate some code from previous versions of jTDS to handle dates, BLobs etc.
  2. This class contains routines to generate runtime messages from the resource file.
  3. The key data conversion logic used in Statements and result sets is implemented here.
  4. There is nothing here which is TDS specific.

author:
   Mike Hutchinson
author:
   jTDS project
version:
   $Id: Support.java,v 1.56 2007/07/08 18:42:14 bheineman Exp $




Method Summary
static  intcalculateNamedPipeBufferSize(int tdsVersion, int packetSize)
     Calculate the buffer size to use when buffering the InputStream for named pipes.

The buffer size is tied directly to the packet size because each request to the SmbNamedPipe will send a request for a particular size of packet.

static  Objectconvert(Object callerReference, Object x, int jdbcType, String charSet)
     Convert an existing data object to the specified JDBC type.
public static  ObjectconvertLOB(Object value)
     Converts a LOB to the equivalent Java type, i.e.
public static  intconvertLOBType(int type)
     Converts a LOB type constant to the equivalent Java type constant, i.e. Types.CLOB to Types.LONGVARCHAR and Types.BLOB to Types.LONGVARBINARY.
static  voidembedData(StringBuffer buf, Object value, boolean isUnicode, ConnectionJDBC2 connection)
     Embed the data object as a string literal in the buffer supplied.
static  byte[]encodeString(String cs, String value)
     Encode a string into a byte array using the specified character set.
Parameters:
  cs - The Charset name.
Parameters:
  value - The value to encode.
static  StringgetClassName(int jdbcType)
     Retrieve the fully qualified java class name for the supplied JDBC Types constant.
Parameters:
  jdbcType - The JDBC Types constant.
static  intgetJdbcType(Object value)
     Get the JDBC type constant which matches the supplied Object type.
Parameters:
  value - The object to analyse.
static  intgetJdbcType(Class typeClass)
     Get the JDBC type constant which matches the supplied Class.
static  StringgetJdbcTypeName(int jdbcType)
     Get a String describing the supplied JDBC type constant.
Parameters:
  jdbcType - The constant to be decoded.
static  StringgetParameterDefinitions(ParamInfo[] parameters)
     Constructs a parameter definition string for use with sp_executesql, sp_prepare, sp_prepexec, sp_cursoropen, sp_cursorprepare and sp_cursorprepexec.
static  StringgetStatementKey(String sql, ParamInfo[] params, int serverType, String catalog, boolean autoCommit, boolean cursor)
     Generates a unique statement key for a given SQL statement.
public static  booleanisWindowsOS()
     Checks the os.name system property to see if it starts with "windows".
public static  SQLWarninglinkException(SQLWarning sqle, Throwable cause)
     Link the original cause to an SQLWarning.

This convenience method calls Support.linkException(Exception,Throwable) and casts the result for cleaner code elsewhere.
Parameters:
  sqle - The SQLWarning to enhance.
Parameters:
  cause - The Throwable to link.

public static  SQLExceptionlinkException(SQLException sqle, Throwable cause)
     Link the original cause to an SQLException.

This convenience method calls Support.linkException(Exception,Throwable) and casts the result for cleaner code elsewhere.
Parameters:
  sqle - The SQLException to enhance.
Parameters:
  cause - The Throwable to link.

public static  ThrowablelinkException(Exception exception, Throwable cause)
     Link the original cause to an Exception.

If running under JVM 1.4+ the Throwable.initCause(Throwable) method will be invoked to chain the exception, else the exception is logged via the Logger class. Modeled after the code written by Brian Heineman.
Parameters:
  exception - The Exception to enhance.
Parameters:
  cause - The Throwable to link.

static  BigDecimalnormalizeBigDecimal(BigDecimal value, int maxPrecision)
     Normalize a BigDecimal value so that it fits within the available precision.
Parameters:
  value - The decimal value to normalize.
Parameters:
  maxPrecision - The decimal precision supported by the server(assumed to be a value of either 28 or 38).
static  StringsubstituteParamMarkers(String sql, ParamInfo[] list)
     Update the SQL string and replace the ? markers with parameter names eg @P0, @P1 etc.
static  StringsubstituteParameters(String sql, ParamInfo[] list, ConnectionJDBC2 connection)
     Substitute actual data for the parameter markers to simulate parameter substitution in a PreparedStatement.
Parameters:
  sql - The SQL containing parameter markers to substitute.
Parameters:
  list - The parameter descriptors.
Parameters:
  connection - The current connection.
public static  longtimeFromZone(java.util.Date value, Calendar target)
     Convert a timestamp from a different Timezone.
Parameters:
  value - the timestamp value.
Parameters:
  target - the Calendar containing the TimeZone.
public static  longtimeToZone(java.util.Date value, Calendar target)
     Convert a timestamp to a different Timezone.
public static  StringtoHex(byte[] bytes)
     Convert a byte[] object to a hex string.
Parameters:
  bytes - The byte array to convert.



Method Detail
calculateNamedPipeBufferSize
static int calculateNamedPipeBufferSize(int tdsVersion, int packetSize)(Code)
Calculate the buffer size to use when buffering the InputStream for named pipes.

The buffer size is tied directly to the packet size because each request to the SmbNamedPipe will send a request for a particular size of packet. In other words, if you only request 1 byte, the SmbNamedPipe will send a request out and only ask for 1 byte back. Buffering the expected packet size ensures that all of the data will be returned in the buffer without wasting any space.
Parameters:
  tdsVersion - the TDS version for the connection
Parameters:
  packetSize - requested packet size for the connection minimum default packet size if packetSize == 0,else packetSize




convert
static Object convert(Object callerReference, Object x, int jdbcType, String charSet) throws SQLException(Code)
Convert an existing data object to the specified JDBC type.
Parameters:
  callerReference - an object reference to the caller of this method;must be a Connection,Statement or ResultSet
Parameters:
  x - the data object to convert
Parameters:
  jdbcType - the required type constant fromjava.sql.Types the converted data object
throws:
  SQLException - if the conversion is not supported or fails



convertLOB
public static Object convertLOB(Object value) throws SQLException(Code)
Converts a LOB to the equivalent Java type, i.e. Clob to String and Blob to byte[]. If the value passed is not a LOB object, it is left unchanged and no exception is thrown; the idea is to transparently convert only LOBs.
Parameters:
  value - an object that may be a LOB if the value was a LOB, the equivalent Java object, otherwisethe original value
throws:
  SQLException - if an error occurs while reading the LOB contents



convertLOBType
public static int convertLOBType(int type)(Code)
Converts a LOB type constant to the equivalent Java type constant, i.e. Types.CLOB to Types.LONGVARCHAR and Types.BLOB to Types.LONGVARBINARY. If the type passed is not that of a LOB, it is left unchanged and no exception is thrown; the idea is to transparently convert only LOB types.
Parameters:
  type - a Types constant defining a JDBC type, possibly aLOB if the type was that of a LOB, the equivalent Java object type,otherwise the original type



embedData
static void embedData(StringBuffer buf, Object value, boolean isUnicode, ConnectionJDBC2 connection) throws SQLException(Code)
Embed the data object as a string literal in the buffer supplied.
Parameters:
  buf - The buffer in which the data will be embeded.
Parameters:
  value - The data object.
Parameters:
  isUnicode - Set to true if Unicode strings should be used, else false.
Parameters:
  connection - The ConnectionJDBC2 object.



encodeString
static byte[] encodeString(String cs, String value)(Code)
Encode a string into a byte array using the specified character set.
Parameters:
  cs - The Charset name.
Parameters:
  value - The value to encode. The value of the String as a byte[].



getClassName
static String getClassName(int jdbcType)(Code)
Retrieve the fully qualified java class name for the supplied JDBC Types constant.
Parameters:
  jdbcType - The JDBC Types constant. The fully qualified java class name as a String.



getJdbcType
static int getJdbcType(Object value)(Code)
Get the JDBC type constant which matches the supplied Object type.
Parameters:
  value - The object to analyse. The JDBC type constant as an int.



getJdbcType
static int getJdbcType(Class typeClass)(Code)
Get the JDBC type constant which matches the supplied Class.
Parameters:
  typeClass - the Class to analyse the JDBC type constant as an int



getJdbcTypeName
static String getJdbcTypeName(int jdbcType)(Code)
Get a String describing the supplied JDBC type constant.
Parameters:
  jdbcType - The constant to be decoded. The text decode of the type constant as a String.



getParameterDefinitions
static String getParameterDefinitions(ParamInfo[] parameters)(Code)
Constructs a parameter definition string for use with sp_executesql, sp_prepare, sp_prepexec, sp_cursoropen, sp_cursorprepare and sp_cursorprepexec.
Parameters:
  parameters - Parameters to construct the definition for a parameter definition string



getStatementKey
static String getStatementKey(String sql, ParamInfo[] params, int serverType, String catalog, boolean autoCommit, boolean cursor)(Code)
Generates a unique statement key for a given SQL statement.
Parameters:
  sql - the sql statment to generate the key for
Parameters:
  params - the statement parameters
Parameters:
  serverType - the type of server to generate the key for
Parameters:
  catalog - the catalog is required for uniqueness on MicrosoftSQL Server
Parameters:
  autoCommit - true if in auto commit mode
Parameters:
  cursor - true if this is a prepared cursor the unique statement key



isWindowsOS
public static boolean isWindowsOS()(Code)
Checks the os.name system property to see if it starts with "windows". true if os.name starts with "windows",else false.



linkException
public static SQLWarning linkException(SQLWarning sqle, Throwable cause)(Code)
Link the original cause to an SQLWarning.

This convenience method calls Support.linkException(Exception,Throwable) and casts the result for cleaner code elsewhere.
Parameters:
  sqle - The SQLWarning to enhance.
Parameters:
  cause - The Throwable to link. The original SQLWarning object.




linkException
public static SQLException linkException(SQLException sqle, Throwable cause)(Code)
Link the original cause to an SQLException.

This convenience method calls Support.linkException(Exception,Throwable) and casts the result for cleaner code elsewhere.
Parameters:
  sqle - The SQLException to enhance.
Parameters:
  cause - The Throwable to link. The original SQLException object.




linkException
public static Throwable linkException(Exception exception, Throwable cause)(Code)
Link the original cause to an Exception.

If running under JVM 1.4+ the Throwable.initCause(Throwable) method will be invoked to chain the exception, else the exception is logged via the Logger class. Modeled after the code written by Brian Heineman.
Parameters:
  exception - The Exception to enhance.
Parameters:
  cause - The Throwable to link. The original Exception object.




normalizeBigDecimal
static BigDecimal normalizeBigDecimal(BigDecimal value, int maxPrecision) throws SQLException(Code)
Normalize a BigDecimal value so that it fits within the available precision.
Parameters:
  value - The decimal value to normalize.
Parameters:
  maxPrecision - The decimal precision supported by the server(assumed to be a value of either 28 or 38). The possibly normalized decimal value as a BigDecimal.
throws:
  SQLException - If the number is too big.



substituteParamMarkers
static String substituteParamMarkers(String sql, ParamInfo[] list)(Code)
Update the SQL string and replace the ? markers with parameter names eg @P0, @P1 etc.
Parameters:
  sql - the SQL containing markers to substitute
Parameters:
  list - the parameter list the modified SQL as a String



substituteParameters
static String substituteParameters(String sql, ParamInfo[] list, ConnectionJDBC2 connection) throws SQLException(Code)
Substitute actual data for the parameter markers to simulate parameter substitution in a PreparedStatement.
Parameters:
  sql - The SQL containing parameter markers to substitute.
Parameters:
  list - The parameter descriptors.
Parameters:
  connection - The current connection. The modified SQL statement.



timeFromZone
public static long timeFromZone(java.util.Date value, Calendar target)(Code)
Convert a timestamp from a different Timezone.
Parameters:
  value - the timestamp value.
Parameters:
  target - the Calendar containing the TimeZone. The new timestamp value as a long.



timeToZone
public static long timeToZone(java.util.Date value, Calendar target)(Code)
Convert a timestamp to a different Timezone.
Parameters:
  value - the timestamp value
Parameters:
  target - the Calendar containing the TimeZone the new timestamp value as a long



toHex
public static String toHex(byte[] bytes)(Code)
Convert a byte[] object to a hex string.
Parameters:
  bytes - The byte array to convert. The hex equivalent as a String.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.