Java Doc for TKDBManager.java in  » Content-Management-System » webman » com » teamkonzept » db » 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 » Content Management System » webman » com.teamkonzept.db 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.teamkonzept.db.TKDBManager

All known Subclasses:   com.teamkonzept.webman.db.TKWebmanDBManager,
TKDBManager
public class TKDBManager (Code)
A manager for database connections of an application context.

Each thread is assigned to an application context. For each context this class manages a pool of database connections using an object of class TKDBConnectionManager TKDBConnectionManager .

Having initialized the database pool for each context, a concrete connection is assigned to each thread after the first request, until an explicit release of the connection.

Simultaneously, a thread can maintain several opened connections to different databases. Each context is then assigned to a single connection. By changing the context a thread may switch to another database connection.

This class is never instantiated.


author:
   $Author: alex $
version:
   $Revision: 1.26 $
See Also:   TKDBConnectionManager




Method Summary
public static  voidbeginTransaction()
     Using the methods beginTransaction, commitTransaction and rollbackTransaction, it is possible to encapsulate several queries in one transaction.
public static  voidcloseConnection()
     Closes the connection of the current thread.
public static  voidcloseNonsensitiveQueries()
     Closes all queries within the connection of the actual context, not implementing the interface SensitiveQuery by calling the queries´ close method.
public static  voidcommitTransaction()
    
public static synchronized  voidderegister(boolean doClose)
     Deregisters the current thread from this TKDBManager.
protected static  voidenterContext(Thread currThread, Object nextContext, boolean leaveOldContext)
     Changes the context of the specified thread to the specified nextContext.
public static  voidexecuteAsTran(TKQuery[] queryArray)
     Executes the queries in the specified queryArray within one transaction.
public static  voidfreeConnection()
     Releases the connection of the current thread, so it can be used later.
public static  ConnectiongetConnection()
    
public static  intgetDBVendor()
     Returns the vendor of database out of the connect data within the TKDBConnectionManager responsible for the actual context of the current thread.
public static  TKDBConnectionManagergetManager()
     Returns the TKDBConnectionManager assigned to the actual context of the current thread.
public static  voidlimitConnections(int count)
     Limits the number of opened connections of the current thread to the specified value of count.
public static  TKQuerynewQuery(Class queryClass)
     Returns an instance of the specified queryClass registered in the TKDBConnectionManager responsible for the actual context of the current thread.
public static  voidprepareConnection(Properties prop)
     Sets all values within the TKDBConnectionManager responsible for the context of the current thread, necessary to connect to database.
final protected static  voidregister(Thread currThread)
     Registers the specified thread at this TKDBManager.
public static  voidregister()
     Registers the current thread at this TKDBManager.
public static  voidregister(Object initialContext)
     Registers the current thread at this TKDBManager and sets the specified context as its initial context.
protected static  voidresetContext()
     Closes all opened connections in the TKDBConnectionManager assigned to the current thread.
public static  voidrollbackTransaction()
    
public static  voidsafeRollbackTransaction(Throwable t)
     Rollbacks a transaction begun in the TKDBConnection in the actual context of the current thread (connection is retrieved over TKDBConnectionManager).



Method Detail
beginTransaction
public static void beginTransaction() throws SQLException(Code)
Using the methods beginTransaction, commitTransaction and rollbackTransaction, it is possible to encapsulate several queries in one transaction.
Usage:
 TKDBManager.beginTransaction();
 try{
 q_1.execute();
 q_1.close();
 .
 .
 .
 q_n.execute();
 q_n.close();
 commitTransaction();
 }
 catch(Throwable e){
 TKDBManager.rollbackTransaction();
 }
 

It is important to call close for each TKQuery, because only then the statement will be completed and SQLExceptions will be thrown.
As well important is to catch Throwable, because close may throw a SQLError!
For details see method TKDBManager.executeAsTran(TKQuery[] queryArray) executeAsTran
throws:
  SQLException -



closeConnection
public static void closeConnection() throws SQLException(Code)
Closes the connection of the current thread.



closeNonsensitiveQueries
public static void closeNonsensitiveQueries() throws SQLException(Code)
Closes all queries within the connection of the actual context, not implementing the interface SensitiveQuery by calling the queries´ close method.
throws:
  SQLException -



commitTransaction
public static void commitTransaction() throws SQLException(Code)
Commits a transaction begun in the TKDBConnection in the actual context of the current thread (connection is retrieved over TKDBConnectionManager)
throws:
  SQLException -



deregister
public static synchronized void deregister(boolean doClose) throws SQLException(Code)
Deregisters the current thread from this TKDBManager. The specified value of doClose indicates, if all the connections contained in the TKDBConnectionManager assigned to the current thread are closed or only released.
Parameters:
  doClose - if true close connections of the current threadelse only release them for other threads.
throws:
  SLQException - normaler SQL Fehler



enterContext
protected static void enterContext(Thread currThread, Object nextContext, boolean leaveOldContext) throws SQLException(Code)
Changes the context of the specified thread to the specified nextContext. Depending on the specified value of leaveOldContext, the connection in the previous context is released.
Parameters:
  currThread - the thread, of which the context has to be changed.
Parameters:
  nextContext - this context replaces the previous context of the specified thread.
Parameters:
  leaveOldContext - indicates if the connection in the previous context is released.
throws:
  SQLException - normaler SQL Fehler



executeAsTran
public static void executeAsTran(TKQuery[] queryArray)(Code)
Executes the queries in the specified queryArray within one transaction. If one TKQuery throws an exception, all queries are rollbacked.
This method should be used, if the returned resultsets are not needed.
Parameters:
  queryArray - Array of TKQuery, to be executed within a transaction



freeConnection
public static void freeConnection() throws SQLException(Code)
Releases the connection of the current thread, so it can be used later.



getConnection
public static Connection getConnection() throws SQLException(Code)
Returns the connection of the current thread in the actual context
throws:
  SQLException -



getDBVendor
public static int getDBVendor()(Code)
Returns the vendor of database out of the connect data within the TKDBConnectionManager responsible for the actual context of the current thread.



getManager
public static TKDBConnectionManager getManager()(Code)
Returns the TKDBConnectionManager assigned to the actual context of the current thread. the connection manager of the current thread.



limitConnections
public static void limitConnections(int count)(Code)
Limits the number of opened connections of the current thread to the specified value of count.



newQuery
public static TKQuery newQuery(Class queryClass) throws SQLException(Code)
Returns an instance of the specified queryClass registered in the TKDBConnectionManager responsible for the actual context of the current thread.
Parameters:
  queryClass - the class to instantiate a new TKQuery
See Also:   TKQuery
See Also:   TKDBConnectionManager
See Also:   TKDBConnection die erzeugte Query



prepareConnection
public static void prepareConnection(Properties prop) throws SQLException(Code)
Sets all values within the TKDBConnectionManager responsible for the context of the current thread, necessary to connect to database.
Parameters:
  dbId - a string which determines the vendor of the used database
Parameters:
  serverId - the connect string
Parameters:
  prop - properties of the used database connection(database, user_name, password, server, ...)



register
final protected static void register(Thread currThread)(Code)
Registers the specified thread at this TKDBManager.
Parameters:
  currThread - the thread to be registered.



register
public static void register()(Code)
Registers the current thread at this TKDBManager.



register
public static void register(Object initialContext)(Code)
Registers the current thread at this TKDBManager and sets the specified context as its initial context.
Parameters:
  initialContext - the initial context to be assigned to the current thread.



resetContext
protected static void resetContext()(Code)
Closes all opened connections in the TKDBConnectionManager assigned to the current thread.



rollbackTransaction
public static void rollbackTransaction() throws SQLException(Code)
Rollbacks a transaction begun in the TKDBConnection in the actual context of the current thread (connection is retrieved over TKDBConnectionManager)



safeRollbackTransaction
public static void safeRollbackTransaction(Throwable t)(Code)
Rollbacks a transaction begun in the TKDBConnection in the actual context of the current thread (connection is retrieved over TKDBConnectionManager).
Is called by executeAsTran(TKQuery [] queryArray) executeAsTran in the catch-clause and analyzes the specified Throwable. Throws a TKSQLError, which encapsulates a SQLException.
Parameters:
  t - Ursprungsexception



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.