Java Doc for DbConnectionManager.java in  » Net » openfire » org » jivesoftware » database » 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 » Net » openfire » org.jivesoftware.database 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.jivesoftware.database.DbConnectionManager

DbConnectionManager
public class DbConnectionManager (Code)
Central manager of database connections. All methods are static so that they can be easily accessed throughout the classes in the database package.

This class also provides a set of utility methods that abstract out operations that may not work on all databases such as setting the max number or rows that a query should return.
author:
   Jive Software
See Also:   ConnectionProvider


Inner Class :public static enum DatabaseType



Method Summary
public static  voidcloseConnection(ResultSet rs, Statement stmt, Connection con)
     Closes a result set, statement and database connection (returning the connection to the connection pool).
public static  voidcloseConnection(Statement stmt, Connection con)
     Closes a statement and database connection (returning the connection to the connection pool).
public static  voidcloseConnection(Connection con)
     Closes a database connection (returning the connection to the connection pool).
public static  voidcloseResultSet(ResultSet rs)
     Closes a result set.
public static  voidcloseStatement(Statement stmt)
     Closes a statement.
public static  voidcloseTransactionConnection(PreparedStatement pstmt, Connection con, boolean abortTransaction)
     Closes a PreparedStatement and Connection.
public static  voidcloseTransactionConnection(Connection con, boolean abortTransaction)
     Closes a Connection.
public static  PreparedStatementcreateScrollablePreparedStatement(Connection con, String sql)
     Creates a scroll insensitive PreparedStatement if the JDBC driver supports it, or a normal PreparedStatement otherwise.
Parameters:
  con - the database connection.
Parameters:
  sql - the SQL to create the PreparedStatement with.
public static  StatementcreateScrollableStatement(Connection con)
     Creates a scroll insensitive Statement if the JDBC driver supports it, or a normal Statement otherwise.
Parameters:
  con - the database connection.
public static  voiddestroyConnectionProvider()
     Destroys the currennt connection provider.
public static  ConnectiongetConnection()
     Returns a database connection from the currently active connection provider.
public static  ConnectionProvidergetConnectionProvider()
     Returns the current connection provider.
public static  DatabaseTypegetDatabaseType()
     Returns the database type.
public static  StringgetLargeTextField(ResultSet rs, int columnIndex)
     Retrives a large text column from a result set, automatically performing streaming if the JDBC driver requires it.
public static  SchemaManagergetSchemaManager()
     Returns a SchemaManager instance, which can be used to manage the database schema information for Openfire and plugins.
public static  ConnectiongetTransactionConnection()
     Returns a Connection from the currently active connection provider that is ready to participate in transactions (auto commit is set to false).
public static  booleanisBatchUpdatesSupported()
    
public static  booleanisEmbeddedDB()
    
public static  booleanisFetchSizeSupported()
    
public static  booleanisMaxRowsSupported()
    
public static  booleanisProfilingEnabled()
     Returns true if connection profiling is turned on.
public static  booleanisScrollResultsSupported()
    
public static  booleanisStreamTextRequired()
    
public static  booleanisSubqueriesSupported()
    
public static  booleanisTransactionsSupported()
    
public static  voidscrollResultSet(ResultSet rs, int rowNumber)
     Scrolls forward in a result set the specified number of rows.
public static  voidsetConnectionProvider(ConnectionProvider provider)
     Sets the connection provider.
public static  voidsetFetchSize(ResultSet rs, int fetchSize)
     Sets the number of rows that the JDBC driver should buffer at a time.
public static  voidsetLargeTextField(PreparedStatement pstmt, int parameterIndex, String value)
     Sets a large text column in a result set, automatically performing streaming if the JDBC driver requires it.
public static  voidsetMaxRows(Statement stmt, int maxRows)
     Sets the max number of rows that should be returned from executing a statement.
public static  voidsetProfilingEnabled(boolean enable)
     Turns connection profiling on or off.



Method Detail
closeConnection
public static void closeConnection(ResultSet rs, Statement stmt, Connection con)(Code)
Closes a result set, statement and database connection (returning the connection to the connection pool). This method should be called within the finally section of your database logic, as in the following example:
 Connection con = null;
 PrepatedStatment pstmt = null;
 ResultSet rs = null;
 try {
 con = ConnectionManager.getConnection();
 pstmt = con.prepareStatement("select * from blah");
 rs = psmt.executeQuery();
 ....
 }
 catch (SQLException sqle) {
 Log.error(sqle);
 }
 finally {
 ConnectionManager.closeConnection(rs, pstmt, con);
 }

Parameters:
  rs - the result set.
Parameters:
  stmt - the statement.
Parameters:
  con - the connection.



closeConnection
public static void closeConnection(Statement stmt, Connection con)(Code)
Closes a statement and database connection (returning the connection to the connection pool). This method should be called within the finally section of your database logic, as in the following example:

 Connection con = null;
 PrepatedStatment pstmt = null;
 try {
 con = ConnectionManager.getConnection();
 pstmt = con.prepareStatement("select * from blah");
 ....
 }
 catch (SQLException sqle) {
 Log.error(sqle);
 }
 finally {
 DbConnectionManager.closeConnection(pstmt, con);
 }

Parameters:
  stmt - the statement.
Parameters:
  con - the connection.



closeConnection
public static void closeConnection(Connection con)(Code)
Closes a database connection (returning the connection to the connection pool). Any statements associated with the connection should be closed before calling this method. This method should be called within the finally section of your database logic, as in the following example:

 Connection con = null;
 try {
 con = ConnectionManager.getConnection();
 ....
 }
 catch (SQLException sqle) {
 Log.error(sqle);
 }
 finally {
 DbConnectionManager.closeConnection(con);
 }

Parameters:
  con - the connection.



closeResultSet
public static void closeResultSet(ResultSet rs)(Code)
Closes a result set. This method should be called within the finally section of your database logic, as in the following example:
 public void doSomething(Connection con) {
 ResultSet rs = null;
 PreparedStatement pstmt = null;
 try {
 pstmt = con.prepareStatement("select * from blah");
 rs = pstmt.executeQuery();
 ....
 }
 catch (SQLException sqle) {
 Log.error(sqle);
 }
 finally {
 ConnectionManager.closeResultSet(rs);
 ConnectionManager.closePreparedStatement(pstmt);
 }
 } 

Parameters:
  rs - the result set to close.



closeStatement
public static void closeStatement(Statement stmt)(Code)
Closes a statement. This method should be called within the finally section of your database logic, as in the following example:
 public void doSomething(Connection con) {
 PreparedStatement pstmt = null;
 try {
 pstmt = con.prepareStatement("select * from blah");
 ....
 }
 catch (SQLException sqle) {
 Log.error(sqle);
 }
 finally {
 ConnectionManager.closePreparedStatement(pstmt);
 }
 } 

Parameters:
  stmt - the statement.



closeTransactionConnection
public static void closeTransactionConnection(PreparedStatement pstmt, Connection con, boolean abortTransaction)(Code)
Closes a PreparedStatement and Connection. However, it first rolls back the transaction or commits it depending on the value of abortTransaction.
Parameters:
  pstmt - the prepared statement to close.
Parameters:
  con - the connection to close.
Parameters:
  abortTransaction - true if the transaction should be rolled back.



closeTransactionConnection
public static void closeTransactionConnection(Connection con, boolean abortTransaction)(Code)
Closes a Connection. However, it first rolls back the transaction or commits it depending on the value of abortTransaction.
Parameters:
  con - the connection to close.
Parameters:
  abortTransaction - true if the transaction should be rolled back.



createScrollablePreparedStatement
public static PreparedStatement createScrollablePreparedStatement(Connection con, String sql) throws SQLException(Code)
Creates a scroll insensitive PreparedStatement if the JDBC driver supports it, or a normal PreparedStatement otherwise.
Parameters:
  con - the database connection.
Parameters:
  sql - the SQL to create the PreparedStatement with. a PreparedStatement
throws:
  java.sql.SQLException - if an error occurs.



createScrollableStatement
public static Statement createScrollableStatement(Connection con) throws SQLException(Code)
Creates a scroll insensitive Statement if the JDBC driver supports it, or a normal Statement otherwise.
Parameters:
  con - the database connection. a Statement
throws:
  SQLException - if an error occurs.



destroyConnectionProvider
public static void destroyConnectionProvider()(Code)
Destroys the currennt connection provider. Future calls to DbConnectionManager.getConnectionProvider() will return null until a new ConnectionProvider is set, or one is automatically loaded by a call to DbConnectionManager.getConnection() .



getConnection
public static Connection getConnection() throws SQLException(Code)
Returns a database connection from the currently active connection provider. (auto commit is set to true). a connection.
throws:
  SQLException - if a SQL exception occurs.



getConnectionProvider
public static ConnectionProvider getConnectionProvider()(Code)
Returns the current connection provider. The only case in which this method should be called is if more information about the current connection provider is needed. Database connections should always be obtained by calling the getConnection method of this class. the connection provider.



getDatabaseType
public static DatabaseType getDatabaseType()(Code)
Returns the database type. The possible types are constants of the DatabaseType class. Any database that doesn't have its own constant falls into the "Other" category. the database type.



getLargeTextField
public static String getLargeTextField(ResultSet rs, int columnIndex) throws SQLException(Code)
Retrives a large text column from a result set, automatically performing streaming if the JDBC driver requires it. This is necessary because different JDBC drivers have different capabilities and methods for retrieving large text values.
Parameters:
  rs - the ResultSet to retrieve the text field from.
Parameters:
  columnIndex - the column in the ResultSet of the text field. the String value of the text field.
throws:
  SQLException - if an SQL exception occurs.



getSchemaManager
public static SchemaManager getSchemaManager()(Code)
Returns a SchemaManager instance, which can be used to manage the database schema information for Openfire and plugins. a SchemaManager instance.



getTransactionConnection
public static Connection getTransactionConnection() throws SQLException(Code)
Returns a Connection from the currently active connection provider that is ready to participate in transactions (auto commit is set to false). a connection with transactions enabled.
throws:
  SQLException - if a SQL exception occurs.



isBatchUpdatesSupported
public static boolean isBatchUpdatesSupported()(Code)



isEmbeddedDB
public static boolean isEmbeddedDB()(Code)



isFetchSizeSupported
public static boolean isFetchSizeSupported()(Code)



isMaxRowsSupported
public static boolean isMaxRowsSupported()(Code)



isProfilingEnabled
public static boolean isProfilingEnabled()(Code)
Returns true if connection profiling is turned on. You can collect profiling statistics by using the static methods of the ProfiledConnection class. true if connection profiling is enabled.



isScrollResultsSupported
public static boolean isScrollResultsSupported()(Code)



isStreamTextRequired
public static boolean isStreamTextRequired()(Code)



isSubqueriesSupported
public static boolean isSubqueriesSupported()(Code)



isTransactionsSupported
public static boolean isTransactionsSupported()(Code)



scrollResultSet
public static void scrollResultSet(ResultSet rs, int rowNumber) throws SQLException(Code)
Scrolls forward in a result set the specified number of rows. If the JDBC driver supports the feature, the cursor will be moved directly. Otherwise, we scroll through results one by one manually by calling rs.next().
Parameters:
  rs - the ResultSet object to scroll.
Parameters:
  rowNumber - the row number to scroll forward to.
throws:
  SQLException - if an error occurs.



setConnectionProvider
public static void setConnectionProvider(ConnectionProvider provider)(Code)
Sets the connection provider. The old provider (if it exists) is shut down before the new one is started. A connection provider should not be started before being passed to the connection manager because the manager will call the start() method automatically.
Parameters:
  provider - the ConnectionProvider that the manager should obtainconnections from.



setFetchSize
public static void setFetchSize(ResultSet rs, int fetchSize)(Code)
Sets the number of rows that the JDBC driver should buffer at a time. The operation is automatically bypassed if Jive knows that the the JDBC driver or database doesn't support it.
Parameters:
  rs - the ResultSet to set the fetch size for.
Parameters:
  fetchSize - the fetchSize.



setLargeTextField
public static void setLargeTextField(PreparedStatement pstmt, int parameterIndex, String value) throws SQLException(Code)
Sets a large text column in a result set, automatically performing streaming if the JDBC driver requires it. This is necessary because different JDBC drivers have different capabilities and methods for setting large text values.
Parameters:
  pstmt - the PreparedStatement to set the text field in.
Parameters:
  parameterIndex - the index corresponding to the text field.
Parameters:
  value - the String to set.
throws:
  SQLException - if an SQL exception occurs.



setMaxRows
public static void setMaxRows(Statement stmt, int maxRows)(Code)
Sets the max number of rows that should be returned from executing a statement. The operation is automatically bypassed if Jive knows that the the JDBC driver or database doesn't support it.
Parameters:
  stmt - the Statement to set the max number of rows for.
Parameters:
  maxRows - the max number of rows to return.



setProfilingEnabled
public static void setProfilingEnabled(boolean enable)(Code)
Turns connection profiling on or off. You can collect profiling statistics by using the static methods of the ProfiledConnection class.
Parameters:
  enable - true to enable profiling; false to disable.



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.