Java Doc for DBUtil.java in  » Portal » stringbeans-3.5 » com » nabhinc » util » 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 » Portal » stringbeans 3.5 » com.nabhinc.util.db 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.nabhinc.util.db.DBUtil

DBUtil
public class DBUtil (Code)
Provides utility methods to get a database connection. Depending on availability of JTA, the connection is either a pooled connection from a data source, or a direct connection to a database.
author:
   Padmanabh Dabke
author:
   (c) 2001 Nabh Information Systems, Inc. All Rights Reserved.


Field Summary
protected static  Hashtable<String, String>dbuDSFlavorsTable
     Maintains mapping between datasource names and flavor strings.
public static  Hashtable<String, DataSource>dbuLocalDSTable
     Hashtable used to keep the mapping between datasource names and datasource implementations.
public static  booleandbuUseJNDI
    

Constructor Summary
public  DBUtil()
     Do nothing constructor.

Method Summary
public static  booleanbeginTransaction()
     Starts a transaction only if it has not been started.
public static  booleancheckRelation(String dsName, String sql)
    
public static  booleancheckRelation(DataSource ds, String sql)
    
public static  voidclose(Connection con)
    
public static  voidclose(ResultSet rs)
    
public static  voidclose(java.sql.Statement st)
    
public static  voidcommitTransaction()
     Invokes commit on transaction manager.
public static  HashMapconstructEnumMap(DataSource ds, String sql)
    
public static  booleanexecute(String dsName, String sql, Object[] params)
    
public static  booleanexecute(DataSource ds, String sql, Object[] params)
    
public static  booleanexecute(String dsName, String sql)
    
public static  booleanexecute(DataSource ds, String sql)
    
public static  java.sql.ConnectiongetConnection()
     Gets a datbase connection.
public static  ConnectiongetConnection(String dsName)
     Gets a datbase connection from a datasource that is looked up using the given JNDI.
public static  intgetCount(String dsName, String sql, Object[] params)
     Assumes that the specified SQL query returns a number.
public static  intgetCount(DataSource ds, String sql, Object[] params)
     Assumes that the specified SQL query returns a number.
public static  DataSourcegetDataSource(String dsName)
     Gets a datbase connection from a datasource that is looked up using the given JNDI.
public static  StringgetDataSourceFlavor(String dsName)
    
public static  java.sql.DategetDateField(String dsName, String sql)
    
public static  java.sql.DategetDateField(DataSource ds, String sql)
    
public static  StringgetField(String dsName, String sql, int sqlType, String format)
    
public static  StringgetField(DataSource ds, String sql, int sqlType, String format)
    
public static  StringgetField(String dsName, String sql, int sqlType, String format, Locale locale)
    
public static  StringgetField(DataSource ds, String sql, int sqlType, String format, Locale locale)
    
public static  StringgetField(String dsName, String sql)
    
public static  StringgetField(DataSource ds, String sql)
    
public static  VectorgetFields(String dsName, String sql, int sqlType, String format)
    
public static  VectorgetFields(DataSource ds, String sql, int sqlType, String format)
    
public static  StringgetFormattedValue(ResultSet rs, int colIndex, int colType, String format)
    
public static  StringgetFormattedValue(ResultSet rs, int colIndex, int colType, String format, Locale locale)
    
public static  ConnectiongetJDBCConnection(String dsName)
    
public static  String[]getRecord(String dsName, String sql, int[] sqlTypes, String[] formats)
    
public static  String[]getRecord(String dsName, String sql, int[] sqlTypes, String[] formats, Object[] params)
    
public static  String[]getRecord(DataSource ds, String sql, int[] sqlTypes, String[] formats, Object[] params)
    
public static  String[]getRecord(String dsName, String sql)
    
public static  String[]getRecord(DataSource ds, String sql)
    
public static  VectorgetRecords(String dsName, String sql, int[] sqlTypes, String[] formats)
    
public static  VectorgetRecords(DataSource ds, String sql, int[] sqlTypes, String[] formats)
    
public static  VectorgetRecords(String dsName, String sql)
    
public static  VectorgetRecords(DataSource ds, String sql)
    
public static  VectorgetRecordsHelper(Connection conn, String sql, int[] sqlTypes, String[] formats)
    
public static  intgetStatus()
    
public static  voidrollbackTransaction()
     Rolls back current transaction.
public static  voidsetRollbackOnly()
     Mark current transaction for rollback.

Field Detail
dbuDSFlavorsTable
protected static Hashtable<String, String> dbuDSFlavorsTable(Code)
Maintains mapping between datasource names and flavor strings.



dbuLocalDSTable
public static Hashtable<String, DataSource> dbuLocalDSTable(Code)
Hashtable used to keep the mapping between datasource names and datasource implementations.



dbuUseJNDI
public static boolean dbuUseJNDI(Code)




Constructor Detail
DBUtil
public DBUtil()(Code)
Do nothing constructor.




Method Detail
beginTransaction
public static boolean beginTransaction() throws Exception(Code)
Starts a transaction only if it has not been started. true if a new transaction was started
exception:
  java.sql.SQLException - Database exception.



checkRelation
public static boolean checkRelation(String dsName, String sql) throws SQLException, NamingException(Code)

Parameters:
  dsName -
Parameters:
  sql -
throws:
  SQLException -
throws:
  NamingException -



checkRelation
public static boolean checkRelation(DataSource ds, String sql) throws SQLException(Code)

Parameters:
  ds -
Parameters:
  sql -
throws:
  SQLException -
throws:
  NamingException -



close
public static void close(Connection con)(Code)



close
public static void close(ResultSet rs)(Code)



close
public static void close(java.sql.Statement st)(Code)



commitTransaction
public static void commitTransaction() throws Exception(Code)
Invokes commit on transaction manager.
exception:
  java.sql.SQLException - Database exception.



constructEnumMap
public static HashMap constructEnumMap(DataSource ds, String sql) throws SQLException(Code)



execute
public static boolean execute(String dsName, String sql, Object[] params) throws SQLException, NamingException(Code)

Parameters:
  dsName -
Parameters:
  sql -
Parameters:
  params -
throws:
  SQLException -
throws:
  NamingException -



execute
public static boolean execute(DataSource ds, String sql, Object[] params) throws SQLException(Code)

Parameters:
  dsName -
Parameters:
  sql -
Parameters:
  params -
throws:
  SQLException -
throws:
  NamingException -



execute
public static boolean execute(String dsName, String sql) throws SQLException, NamingException(Code)

Parameters:
  dsName -
Parameters:
  sql -
throws:
  SQLException -
throws:
  NamingException -



execute
public static boolean execute(DataSource ds, String sql) throws SQLException(Code)

Parameters:
  ds -
Parameters:
  sql -
throws:
  SQLException -
throws:
  NamingException -



getConnection
public static java.sql.Connection getConnection() throws java.sql.SQLException, NamingException(Code)
Gets a datbase connection. Database connection
exception:
  java.sql.SQLException -



getConnection
public static Connection getConnection(String dsName) throws java.sql.SQLException, javax.naming.NamingException(Code)
Gets a datbase connection from a datasource that is looked up using the given JNDI. Note that this will not work in the non-j2ee configuration
Parameters:
  dsName - JNDI name for the datasource Database connection
exception:
  java.sql.SQLException -



getCount
public static int getCount(String dsName, String sql, Object[] params) throws SQLException, NamingException(Code)
Assumes that the specified SQL query returns a number. This will happen if you have statements like "SELECT COUNT(*) ...". It extracts and returns the number.
Parameters:
  dsName - Data source name.
Parameters:
  sql - SQL query statement that return int as the result, e.g. SELECT SUM(column_name)....
Parameters:
  Optional - subtitutes parameter used in prepare statement.



getCount
public static int getCount(DataSource ds, String sql, Object[] params) throws SQLException(Code)
Assumes that the specified SQL query returns a number. This will happen if you have statements like "SELECT COUNT(*) ...". It extracts and returns the number.
Parameters:
  dsName - Data source name.
Parameters:
  sql - SQL query statement that return int as the result, e.g. SELECT SUM(column_name)....
Parameters:
  Optional - subtitutes parameter used in prepare statement.



getDataSource
public static DataSource getDataSource(String dsName) throws javax.naming.NamingException(Code)
Gets a datbase connection from a datasource that is looked up using the given JNDI. Note that this will not work in the non-j2ee configuration
Parameters:
  dsName - JNDI name for the datasource Database connection
exception:
  java.sql.SQLException -



getDataSourceFlavor
public static String getDataSourceFlavor(String dsName)(Code)



getDateField
public static java.sql.Date getDateField(String dsName, String sql) throws SQLException, NamingException(Code)



getDateField
public static java.sql.Date getDateField(DataSource ds, String sql) throws SQLException(Code)



getField
public static String getField(String dsName, String sql, int sqlType, String format) throws SQLException, NamingException(Code)

Parameters:
  dsName -
Parameters:
  sql -
Parameters:
  sqlType -
Parameters:
  format -
throws:
  SQLException -
throws:
  NamingException -



getField
public static String getField(DataSource ds, String sql, int sqlType, String format) throws SQLException(Code)

Parameters:
  ds -
Parameters:
  sql -
Parameters:
  sqlType -
Parameters:
  format -
throws:
  SQLException -
throws:
  NamingException -



getField
public static String getField(String dsName, String sql, int sqlType, String format, Locale locale) throws SQLException, NamingException(Code)
Date and Timestamp are formatted based on Locale provided (optional)
Parameters:
  dsName -
Parameters:
  sql -
Parameters:
  sqlType -
Parameters:
  format -
Parameters:
  locale -
throws:
  SQLException -
throws:
  NamingException -



getField
public static String getField(DataSource ds, String sql, int sqlType, String format, Locale locale) throws SQLException(Code)
Date and Timestamp are formatted based on Locale provided (optional)
Parameters:
  ds -
Parameters:
  sql -
Parameters:
  sqlType -
Parameters:
  format -
Parameters:
  locale -
throws:
  SQLException -
throws:
  NamingException -



getField
public static String getField(String dsName, String sql) throws SQLException, NamingException(Code)



getField
public static String getField(DataSource ds, String sql) throws SQLException(Code)



getFields
public static Vector getFields(String dsName, String sql, int sqlType, String format) throws SQLException, NamingException(Code)

Parameters:
  dsName -
Parameters:
  sql -
Parameters:
  sqlType -
Parameters:
  format -
throws:
  SQLException -
throws:
  NamingException -



getFields
public static Vector getFields(DataSource ds, String sql, int sqlType, String format) throws SQLException(Code)

Parameters:
  ds -
Parameters:
  sql -
Parameters:
  sqlType -
Parameters:
  format -
throws:
  SQLException -
throws:
  NamingException -



getFormattedValue
public static String getFormattedValue(ResultSet rs, int colIndex, int colType, String format) throws SQLException(Code)

Parameters:
  rs -
Parameters:
  colIndex -
Parameters:
  colType -
Parameters:
  format -
throws:
  SQLException -



getFormattedValue
public static String getFormattedValue(ResultSet rs, int colIndex, int colType, String format, Locale locale) throws SQLException(Code)



getJDBCConnection
public static Connection getJDBCConnection(String dsName) throws SQLException, NamingException(Code)



getRecord
public static String[] getRecord(String dsName, String sql, int[] sqlTypes, String[] formats) throws SQLException, NamingException(Code)

Parameters:
  dsName -
Parameters:
  sql -
Parameters:
  sqlTypes -
Parameters:
  formats -
throws:
  SQLException -
throws:
  NamingException -



getRecord
public static String[] getRecord(String dsName, String sql, int[] sqlTypes, String[] formats, Object[] params) throws SQLException, NamingException(Code)

Parameters:
  dsName -
Parameters:
  sql -
Parameters:
  sqlTypes -
Parameters:
  formats -
Parameters:
  params -
throws:
  SQLException -
throws:
  NamingException -



getRecord
public static String[] getRecord(DataSource ds, String sql, int[] sqlTypes, String[] formats, Object[] params) throws SQLException, NamingException(Code)

Parameters:
  dsName -
Parameters:
  sql -
Parameters:
  sqlTypes -
Parameters:
  formats -
Parameters:
  params -
throws:
  SQLException -
throws:
  NamingException -



getRecord
public static String[] getRecord(String dsName, String sql) throws SQLException, NamingException(Code)



getRecord
public static String[] getRecord(DataSource ds, String sql) throws SQLException(Code)



getRecords
public static Vector getRecords(String dsName, String sql, int[] sqlTypes, String[] formats) throws SQLException, NamingException(Code)

Parameters:
  dsName -
Parameters:
  sql -
Parameters:
  sqlTypes -
Parameters:
  formats -
throws:
  SQLException -
throws:
  NamingException -



getRecords
public static Vector getRecords(DataSource ds, String sql, int[] sqlTypes, String[] formats) throws SQLException(Code)

Parameters:
  dsName -
Parameters:
  sql -
Parameters:
  sqlTypes -
Parameters:
  formats -
throws:
  SQLException -
throws:
  NamingException -



getRecords
public static Vector getRecords(String dsName, String sql) throws SQLException, NamingException(Code)



getRecords
public static Vector getRecords(DataSource ds, String sql) throws SQLException(Code)



getRecordsHelper
public static Vector getRecordsHelper(Connection conn, String sql, int[] sqlTypes, String[] formats) throws SQLException(Code)



getStatus
public static int getStatus() throws javax.transaction.SystemException(Code)

throws:
  javax.transaction.SystemException -



rollbackTransaction
public static void rollbackTransaction() throws Exception(Code)
Rolls back current transaction.
exception:
  java.sql.SQLException - The exception description.



setRollbackOnly
public static void setRollbackOnly() throws Exception(Code)
Mark current transaction for rollback.
exception:
  java.sql.SQLException - The exception description.



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.