Java Doc for JtdsStatement.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.JtdsStatement

All known Subclasses:   net.sourceforge.jtds.jdbc.JtdsPreparedStatement,
JtdsStatement
public class JtdsStatement implements java.sql.Statement(Code)
jTDS implementation of the java.sql.Statement interface.

NB. As allowed by the JDBC standard and like most other drivers, this implementation only allows one open result set at a time.

Implementation notes:

I experimented with allowing multiple open result sets as supported by the origianal jTDS but rejected this approach for the following reasons:

  1. It is more difficult to ensure that there are no memory leaks and that cursors are closed if multiple open sets are allowed.
  2. The use of one result set allows cursor and non cursor result sets to be derived from exeuteQuery() or execute() and getResultSet() in the same way that other drivers do.
In the event of an IO failure the setClosed() method forces this statement and associated result set to close preventing the propogation of errors. This class includes a finalize method which increases the chances of the statement being closed tidly in a pooled environment where the user has forgotten to explicitly close the statement before it goes out of scope.
See Also:   java.sql.Statement
See Also:   java.sql.Connection.createStatement
See Also:   java.sql.ResultSet
author:
   Mike Hutchinson
version:
   $Id: JtdsStatement.java,v 1.64 2007/07/12 21:03:23 bheineman Exp $


Field Summary
final static  intBOOLEAN
    
final static  intCLOSE_ALL_RESULTS
    
final static  intCLOSE_CURRENT_RESULT
    
final static  intDATALINK
    
final static  intDEFAULT_FETCH_SIZE
    
final static  IntegerEXECUTE_FAILED
    
final static  intKEEP_CURRENT_RESULT
    
final static  intNO_GENERATED_KEYS
    
final static  intRETURN_GENERATED_KEYS
    
final static  IntegerSUCCESS_NO_INFO
    
protected  ArrayListbatchValues
     Batched SQL Statement array.
protected  booleanclosed
     True if this statement is closed.
protected  ColInfo[]colMetaData
     The cached column meta data.
protected  ConnectionJDBC2connection
     The connection owning this statement object.
protected  JtdsResultSetcurrentResult
     The current ResultSet.
protected  StringcursorName
     The cursor name to be used for positioned updates.
protected  booleanescapeProcessing
     True if SQL statements should be preprocessed.
protected  intfetchDirection
     The fetch direction for result sets.
protected  intfetchSize
     The fetch size (default 100, only used by cursor ResultSets).
protected  JtdsResultSetgenKeyResultSet
     Dummy result set for getGeneratedKeys.
protected  intmaxFieldSize
     The maximum field size (not used at present).
protected  intmaxRows
     The maximum number of rows to return (not used at present).
final protected  SQLDiagnosticmessages
     SQL Diagnostic exceptions and warnings.
protected  ArrayListopenResultSets
     List of open result sets.
protected  intqueryTimeout
    
final protected  LinkedListresultQueue
     List of queued results (update counts, possibly followed by a ResultSet).
protected  intresultSetConcurrency
     The concurrency of result sets created by this statement.
protected  intresultSetType
     The type of result sets created by this statement.
protected  TdsCoretds
     The TDS object used for server access.

Constructor Summary
 JtdsStatement(ConnectionJDBC2 connection, int resultSetType, int resultSetConcurrency)
     Construct a new Statement object.

Method Summary
public  voidaddBatch(String sql)
    
 voidaddWarning(SQLWarning w)
     Add an SQLWarning object to the statment warnings list.
protected  voidcacheResults()
     Cache as many results as possible (up to the first ResultSet).
public  voidcancel()
    
protected  voidcheckCursorException(SQLException e)
     Check that the exception is caused by the failure to open a cursor and not by a more serious SQL error.
protected  voidcheckOpen()
     Check that this statement is still open.
public  voidclearBatch()
    
public  voidclearWarnings()
    
public  voidclose()
    
 voidcloseAllResultSets()
     Close all result sets.
 voidcloseCurrentResultSet()
     Close current result set (if any).
public  booleanexecute(String sql)
    
public  booleanexecute(String sql, int autoGeneratedKeys)
    
public  booleanexecute(String sql, int[] columnIndexes)
    
public  booleanexecute(String sql, String[] columnNames)
    
public  int[]executeBatch()
     Execute batch of SQL Statements.

The JDBC3 standard says that the behaviour of this method must be consistent for any DBMS.

protected  SQLExceptionexecuteMSBatch(int size, int executeSize, ArrayList counts)
     Execute the SQL batch on a MS server.
public  ResultSetexecuteQuery(String sql)
    
protected  booleanexecuteSQL(String sql, String spName, ParamInfo[] params, boolean returnKeys, boolean update, boolean useCursor)
     Executes any type of SQL.
protected  ResultSetexecuteSQLQuery(String sql, String spName, ParamInfo[] params, boolean useCursor)
     Executes SQL to obtain a result set.
protected  SQLExceptionexecuteSybaseBatch(int size, int executeSize, ArrayList counts)
     Execute the SQL batch on a Sybase server.

Sybase needs to have the SQL concatenated into one TDS language packet.

public  intexecuteUpdate(String sql)
    
public  intexecuteUpdate(String sql, int autoGeneratedKeys)
    
public  intexecuteUpdate(String sql, int[] columnIndexes)
    
public  intexecuteUpdate(String sql, String[] columnNames)
    
protected  voidfinalize()
     Called when this object goes out of scope to close any ResultSet object and this statement.
public  ConnectiongetConnection()
    
 intgetDefaultFetchSize()
     Retrieve the default fetch size for this statement.
public  intgetFetchDirection()
    
public  intgetFetchSize()
    
public  ResultSetgetGeneratedKeys()
    
public  intgetMaxFieldSize()
    
public  intgetMaxRows()
    
 SQLDiagnosticgetMessages()
     Get the statement's warnings list.
public  booleangetMoreResults()
    
public  booleangetMoreResults(int current)
    
public  intgetQueryTimeout()
    
public  ResultSetgetResultSet()
    
public  intgetResultSetConcurrency()
    
public  intgetResultSetHoldability()
    
public  intgetResultSetType()
    
 TdsCoregetTds()
     Get the Statement's TDS object.
public  intgetUpdateCount()
    
public  SQLWarninggetWarnings()
    
protected  voidinitialize()
     Initialize the Statement, by cleaning up all queued and unprocessed results.
static  voidnotImplemented(String method)
     Report that user tried to call a method which has not been implemented.
public  voidsetCursorName(String name)
    
public  voidsetEscapeProcessing(boolean enable)
    
public  voidsetFetchDirection(int direction)
    
public  voidsetFetchSize(int rows)
    
public  voidsetMaxFieldSize(int max)
    
public  voidsetMaxRows(int max)
    
public  voidsetQueryTimeout(int seconds)
    
protected  booleanuseCursor(boolean returnKeys, String sqlWord)
     Determines whether a cursor should be used based on the requested result set type and concurrency, whether a cursor name has been set, the useCursors connection property has been set, the first word in the SQL query is either SELECT or EXEC/EXECUTE and no generated keys are returned.

Field Detail
BOOLEAN
final static int BOOLEAN(Code)



CLOSE_ALL_RESULTS
final static int CLOSE_ALL_RESULTS(Code)



CLOSE_CURRENT_RESULT
final static int CLOSE_CURRENT_RESULT(Code)



DATALINK
final static int DATALINK(Code)



DEFAULT_FETCH_SIZE
final static int DEFAULT_FETCH_SIZE(Code)



EXECUTE_FAILED
final static Integer EXECUTE_FAILED(Code)



KEEP_CURRENT_RESULT
final static int KEEP_CURRENT_RESULT(Code)



NO_GENERATED_KEYS
final static int NO_GENERATED_KEYS(Code)



RETURN_GENERATED_KEYS
final static int RETURN_GENERATED_KEYS(Code)



SUCCESS_NO_INFO
final static Integer SUCCESS_NO_INFO(Code)



batchValues
protected ArrayList batchValues(Code)
Batched SQL Statement array.



closed
protected boolean closed(Code)
True if this statement is closed.



colMetaData
protected ColInfo[] colMetaData(Code)
The cached column meta data.



connection
protected ConnectionJDBC2 connection(Code)
The connection owning this statement object.



currentResult
protected JtdsResultSet currentResult(Code)
The current ResultSet.



cursorName
protected String cursorName(Code)
The cursor name to be used for positioned updates.



escapeProcessing
protected boolean escapeProcessing(Code)
True if SQL statements should be preprocessed.



fetchDirection
protected int fetchDirection(Code)
The fetch direction for result sets.



fetchSize
protected int fetchSize(Code)
The fetch size (default 100, only used by cursor ResultSets).



genKeyResultSet
protected JtdsResultSet genKeyResultSet(Code)
Dummy result set for getGeneratedKeys.



maxFieldSize
protected int maxFieldSize(Code)
The maximum field size (not used at present).



maxRows
protected int maxRows(Code)
The maximum number of rows to return (not used at present).



messages
final protected SQLDiagnostic messages(Code)
SQL Diagnostic exceptions and warnings.



openResultSets
protected ArrayList openResultSets(Code)
List of open result sets.



queryTimeout
protected int queryTimeout(Code)
The read query timeout in seconds



resultQueue
final protected LinkedList resultQueue(Code)
List of queued results (update counts, possibly followed by a ResultSet).



resultSetConcurrency
protected int resultSetConcurrency(Code)
The concurrency of result sets created by this statement.



resultSetType
protected int resultSetType(Code)
The type of result sets created by this statement.



tds
protected TdsCore tds(Code)
The TDS object used for server access.




Constructor Detail
JtdsStatement
JtdsStatement(ConnectionJDBC2 connection, int resultSetType, int resultSetConcurrency) throws SQLException(Code)
Construct a new Statement object.
Parameters:
  connection - The parent connection.
Parameters:
  resultSetType - The result set type for example TYPE_FORWARD_ONLY.
Parameters:
  resultSetConcurrency - The concurrency for example CONCUR_READ_ONLY.




Method Detail
addBatch
public void addBatch(String sql) throws SQLException(Code)



addWarning
void addWarning(SQLWarning w)(Code)
Add an SQLWarning object to the statment warnings list.
Parameters:
  w - The SQLWarning to add.



cacheResults
protected void cacheResults() throws SQLException(Code)
Cache as many results as possible (up to the first ResultSet). Called by ResultSets when the end is reached.



cancel
public void cancel() throws SQLException(Code)



checkCursorException
protected void checkCursorException(SQLException e) throws SQLException(Code)
Check that the exception is caused by the failure to open a cursor and not by a more serious SQL error.
Parameters:
  e - the exception returned by the cursor class
throws:
  SQLException - if exception is not due to a cursor error



checkOpen
protected void checkOpen() throws SQLException(Code)
Check that this statement is still open.
throws:
  SQLException - if statement closed.



clearBatch
public void clearBatch() throws SQLException(Code)



clearWarnings
public void clearWarnings() throws SQLException(Code)



close
public void close() throws SQLException(Code)



closeAllResultSets
void closeAllResultSets() throws SQLException(Code)
Close all result sets.



closeCurrentResultSet
void closeCurrentResultSet() throws SQLException(Code)
Close current result set (if any).



execute
public boolean execute(String sql) throws SQLException(Code)



execute
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException(Code)



execute
public boolean execute(String sql, int[] columnIndexes) throws SQLException(Code)



execute
public boolean execute(String sql, String[] columnNames) throws SQLException(Code)



executeBatch
public int[] executeBatch() throws SQLException, BatchUpdateException(Code)
Execute batch of SQL Statements.

The JDBC3 standard says that the behaviour of this method must be consistent for any DBMS. As Sybase (and to a lesser extent SQL Server) will sometimes continue after a batch execution error, the only way to comply with the standard is to always return an array of update counts the same size as the batch list. Slots in the array beyond the last executed statement are set to EXECUTE_FAILED. update counts as an int[]




executeMSBatch
protected SQLException executeMSBatch(int size, int executeSize, ArrayList counts) throws SQLException(Code)
Execute the SQL batch on a MS server.
Parameters:
  size - the total size of the batch
Parameters:
  executeSize - the maximum number of statements to send in one request
Parameters:
  counts - the returned update counts chained exceptions linked to a SQLException
throws:
  SQLException - if a serious error occurs during execution



executeQuery
public ResultSet executeQuery(String sql) throws SQLException(Code)



executeSQL
protected boolean executeSQL(String sql, String spName, ParamInfo[] params, boolean returnKeys, boolean update, boolean useCursor) throws SQLException(Code)
Executes any type of SQL.
Parameters:
  sql - the SQL statement to execute
Parameters:
  spName - optional stored procedure name
Parameters:
  params - optional parameters
Parameters:
  returnKeys - whether the statement returns generated keys
Parameters:
  update - whether the caller is JtdsStatement.executeUpdate
Parameters:
  useCursor - whether the requested result set type or concurrencyor connection properties request usage of a cursor true if the first result is a result set
throws:
  SQLException - if an error condition occurs



executeSQLQuery
protected ResultSet executeSQLQuery(String sql, String spName, ParamInfo[] params, boolean useCursor) throws SQLException(Code)
Executes SQL to obtain a result set.
Parameters:
  sql - the SQL statement to execute
Parameters:
  spName - optional stored procedure name
Parameters:
  params - optional parameters
Parameters:
  useCursor - whether a cursor should be created for the SQL the result set generated by the query



executeSybaseBatch
protected SQLException executeSybaseBatch(int size, int executeSize, ArrayList counts) throws SQLException(Code)
Execute the SQL batch on a Sybase server.

Sybase needs to have the SQL concatenated into one TDS language packet. This method will be overriden for PreparedStatements.
Parameters:
  size - the total size of the batch
Parameters:
  executeSize - the maximum number of statements to send in one request
Parameters:
  counts - the returned update counts chained exceptions linked to a SQLException
throws:
  SQLException - if a serious error occurs during execution




executeUpdate
public int executeUpdate(String sql) throws SQLException(Code)



executeUpdate
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException(Code)



executeUpdate
public int executeUpdate(String sql, int[] columnIndexes) throws SQLException(Code)



executeUpdate
public int executeUpdate(String sql, String[] columnNames) throws SQLException(Code)



finalize
protected void finalize() throws Throwable(Code)
Called when this object goes out of scope to close any ResultSet object and this statement.



getConnection
public Connection getConnection() throws SQLException(Code)



getDefaultFetchSize
int getDefaultFetchSize()(Code)
Retrieve the default fetch size for this statement. the default fetch size for a new ResultSet



getFetchDirection
public int getFetchDirection() throws SQLException(Code)



getFetchSize
public int getFetchSize() throws SQLException(Code)



getGeneratedKeys
public ResultSet getGeneratedKeys() throws SQLException(Code)



getMaxFieldSize
public int getMaxFieldSize() throws SQLException(Code)



getMaxRows
public int getMaxRows() throws SQLException(Code)



getMessages
SQLDiagnostic getMessages()(Code)
Get the statement's warnings list. The warnings list as a SQLDiagnostic.



getMoreResults
public boolean getMoreResults() throws SQLException(Code)



getMoreResults
public boolean getMoreResults(int current) throws SQLException(Code)



getQueryTimeout
public int getQueryTimeout() throws SQLException(Code)



getResultSet
public ResultSet getResultSet() throws SQLException(Code)



getResultSetConcurrency
public int getResultSetConcurrency() throws SQLException(Code)



getResultSetHoldability
public int getResultSetHoldability() throws SQLException(Code)



getResultSetType
public int getResultSetType() throws SQLException(Code)



getTds
TdsCore getTds()(Code)
Get the Statement's TDS object. The TDS support as a TdsCore Object.



getUpdateCount
public int getUpdateCount() throws SQLException(Code)



getWarnings
public SQLWarning getWarnings() throws SQLException(Code)



initialize
protected void initialize() throws SQLException(Code)
Initialize the Statement, by cleaning up all queued and unprocessed results. Called by all execute methods.
throws:
  SQLException - if an error occurs



notImplemented
static void notImplemented(String method) throws SQLException(Code)
Report that user tried to call a method which has not been implemented.
Parameters:
  method - The method name to report in the error message.
throws:
  SQLException -



setCursorName
public void setCursorName(String name) throws SQLException(Code)



setEscapeProcessing
public void setEscapeProcessing(boolean enable) throws SQLException(Code)



setFetchDirection
public void setFetchDirection(int direction) throws SQLException(Code)



setFetchSize
public void setFetchSize(int rows) throws SQLException(Code)



setMaxFieldSize
public void setMaxFieldSize(int max) throws SQLException(Code)



setMaxRows
public void setMaxRows(int max) throws SQLException(Code)



setQueryTimeout
public void setQueryTimeout(int seconds) throws SQLException(Code)



useCursor
protected boolean useCursor(boolean returnKeys, String sqlWord)(Code)
Determines whether a cursor should be used based on the requested result set type and concurrency, whether a cursor name has been set, the useCursors connection property has been set, the first word in the SQL query is either SELECT or EXEC/EXECUTE and no generated keys are returned.
Parameters:
  returnKeys - indicates whether keys will be returned by the query
Parameters:
  sqlWord - the first word in the SQL query; can benull if the caller isJtdsStatement.executeQuery true if a cursor should be used, falseif not



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.