Java Doc for DatabaseDriver.java in  » Workflow-Engines » pegasus-2.1.0 » org » griphyn » vdl » dbdriver » 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 » Workflow Engines » pegasus 2.1.0 » org.griphyn.vdl.dbdriver 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.griphyn.vdl.dbdriver.DatabaseDriver

All known Subclasses:   org.griphyn.vdl.dbdriver.Postgres,  org.griphyn.vdl.dbdriver.SQLServer2000,  org.griphyn.vdl.dbdriver.MySQL,  org.griphyn.vdl.dbdriver.Oracle,  org.griphyn.vdl.dbdriver.SQLite,
DatabaseDriver
abstract public class DatabaseDriver (Code)
This common database interface that defines basic functionalities for interacting with backend SQL database. The implementation usually requires specific attention to the details between different databases, as each does things slightly different. The API provides a functionality that is independent of the schemas to be used.

The schema classes implement all their database access in terms of this database driver classes.

The separation of database driver and schema lowers the implementation cost, as only N driver and M schemas need to be implemented, instead of N x M schema-specific database-specific drivers.
author:
   Jens-S. Vöckler
author:
   Yong Zhao
version:
   $Revision: 50 $
See Also:   org.griphyn.vdl.dbschema



Field Summary
protected  Connectionm_connection
     This variable keeps the JDBC handle for the database connection.
protected  Mapm_prepared
     This list stores the prepared statements by their position. The constructor will initialize it.

Constructor Summary
public  DatabaseDriver()
     Default constructor.

Method Summary
public  booleanaddPreparedStatement(String id, String statement)
     Inserts a new prepared statement into the list of prepared statements.
protected  booleanaddPreparedStatement(String id, String statement, boolean autoGeneratedKeys)
     Inserts a new prepared statement into the list of prepared statements.
public  ResultSetbackdoor(String query)
     Drills a hole into the nice database driver abstraction to the JDBC3 level.
abstract public  booleancachingMakesSense()
     Determines, if the backend is expensive, and results should be cached.
public  voidcancelPreparedStatement(String id)
     Cancels and resets all previous values of a prepared statement.
public  voidclearWarnings()
     Clears all warnings reported for this database driver.
public  voidcommit()
     Commits the latest changes to the database.
protected  booleanconnect(String driver, String url, Properties info, Set tables)
     Establishes a connection to the specified database.
abstract public  booleanconnect(String url, Properties info, Set tables)
     Establish a connection to your database.
public  intdelete(String table, Map columns)
     Removes all rows that match the provided keyset from a table.
Parameters:
  table - is the name of the table to remove values from
Parameters:
  columns - is a set of column names and their associatedvalues to select the removed columns.
public  voiddisconnect()
     Close an established database connection.
public  voiddriverMatch()
     Determines, if the JDBC driver is the right one for the database we talk to.
protected  voidfinalize()
     Closes an open connection to the database whenever this object is destroyed.
public  PreparedStatementgetPreparedStatement(String id)
     Obtains a reference to a prepared statement to be used from the caller.
public  SQLWarninggetWarnings()
     Retrieves the first warning reported by calls on this Connection object.
public  longinsert(String table, Map keycolumns, Map columns)
     Inserts a row in one given database table.
Parameters:
  table - is the name of the table to insert into.
Parameters:
  keycolumns - is a set of primary keys and their associated values.For special tables, the primary key set may be nullor empty (e.g.
public  booleaninsertPreparedStatement(String id, String statement)
     Inserts a new prepared statement into the list of prepared statements.
public static  DatabaseDriverloadDriver(String dbDriverName, String propertyPrefix, Object[] arguments)
     Instantiates the appropriate child according to property values. This method is a factory.
public static  DatabaseDriverloadDriver(String propertyPrefix)
     Convenience method instantiates the appropriate child according to property values.
abstract public  booleanpreferString()
     Predicate to tell the schema, if using a string instead of number will result in the speedier index scans instead of sequential scans.
public  Stringquote(String s)
     Quotes a string that may contain special SQL characters.
Parameters:
  s - is the raw string.
public  voidremovePreparedStatement(String id)
     Explicitely requests a prepared id to be destroyed and its resources freed.
public  voidrollback()
     Rolls back the latest changes to the database.
public  ResultSetselect(List select, String table, Map where, String order)
     Selects any rows in one or more colums from one or more tables restricted by some condition, possibly ordered.
public  ResultSetselect(List select, String table, Map where, Map operator, String order)
     Selects any rows in one or more colums from one or more tables restricted by some condition that allows operators.
abstract public  longsequence1(String name)
     Obtains the next value from a sequence.
abstract public  longsequence2(Statement s, String name, int pos)
     Obtains the sequence value for the current statement.
public  intupdate(String table, Map keycolumns, Map columns)
     Updates matching rows in one given database table.
Parameters:
  table - is the name of the table to insert into.
Parameters:
  keycolumns - is a set of primary keys and their associated values.For special tables, the primary key set may be nullor empty (e.g.

Field Detail
m_connection
protected Connection m_connection(Code)
This variable keeps the JDBC handle for the database connection.



m_prepared
protected Map m_prepared(Code)
This list stores the prepared statements by their position. The constructor will initialize it. Explicit destruction can be requested per statement.




Constructor Detail
DatabaseDriver
public DatabaseDriver()(Code)
Default constructor. As the constructor will do nothing, please use the connect method to obtain a database connection. This is the constructor that will be invoked when dynamically loading a driver.
See Also:   DatabaseDriver.connect(String,Properties,Set)




Method Detail
addPreparedStatement
public boolean addPreparedStatement(String id, String statement) throws SQLException(Code)
Inserts a new prepared statement into the list of prepared statements. If the id is already taken, it will be rejected.
Parameters:
  id - is the id into which to parse the statement
Parameters:
  statement - is the before-parsing statement string true, if the statement was parsed and added at the id,false, if the id was already taken. The statement is not parsedin that case.
exception:
  SQLException - may be thrown by parsing the statement.
See Also:   DatabaseDriver.removePreparedStatement(String)
See Also:   DatabaseDriver.getPreparedStatement(String)
See Also:   DatabaseDriver.cancelPreparedStatement(String)



addPreparedStatement
protected boolean addPreparedStatement(String id, String statement, boolean autoGeneratedKeys) throws SQLException(Code)
Inserts a new prepared statement into the list of prepared statements. If the id is already taken, it will be rejected. This method can only be used with JDBC drivers that support auto-increment columns. It might fail with JDBC drivers that do not support auto-increment columns, depending on the driver's implementation.
Parameters:
  id - is the id into which to parse the statement
Parameters:
  statement - is the before-parsing statement string
Parameters:
  autoGeneratedKeys - is true, if the statement should reservespace to return autoinc columns, false, if the statement does nothave any such keys. true, if the statement was parsed and added at the id,false, if the id was already taken. The statement is not parsedin that case.
exception:
  SQLException - may be thrown by parsing the statement.
See Also:   DatabaseDriver.removePreparedStatement(String)
See Also:   DatabaseDriver.getPreparedStatement(String)
See Also:   DatabaseDriver.cancelPreparedStatement(String)



backdoor
public ResultSet backdoor(String query) throws SQLException(Code)
Drills a hole into the nice database driver abstraction to the JDBC3 level. Use with caution.
Parameters:
  query - is an SQL query statement.
exception:
  SQLException - if something goes wrong during the query



cachingMakesSense
abstract public boolean cachingMakesSense()(Code)
Determines, if the backend is expensive, and results should be cached. Ideally, this will move transparently into the backend itself. true if caching is advisable, false for no caching.



cancelPreparedStatement
public void cancelPreparedStatement(String id) throws SQLException, ArrayIndexOutOfBoundsException(Code)
Cancels and resets all previous values of a prepared statement.
Parameters:
  id - is the id for which to obtain the previouslyprepared statement.
exception:
  SQLException - if a database access error occurs whileclearing the parameters.
exception:
  ArrayIndexOutOfBoundsException - if a non-existing idis being requested.
See Also:   java.sql.PreparedStatement.clearParameters
See Also:   DatabaseDriver.addPreparedStatement(String,String)
See Also:   DatabaseDriver.getPreparedStatement(String)
See Also:   DatabaseDriver.removePreparedStatement(String)



clearWarnings
public void clearWarnings() throws SQLException(Code)
Clears all warnings reported for this database driver. After a call to this method, the internal warnings are cleared until the next one occurs.



commit
public void commit() throws SQLException(Code)
Commits the latest changes to the database.
exception:
  SQLException - is propagated from the commit.



connect
protected boolean connect(String driver, String url, Properties info, Set tables) throws SQLException, ClassNotFoundException(Code)
Establishes a connection to the specified database. The parameters will often be ignored or abused for different purposes on different backends. It is assumed that the connection is not in auto-commit mode, and explicit commits must be issued.

Essentially, the deriving class will overwrite their connect method to fill in the appropriate driver, and otherwise just call this method.
Parameters:
  driver - is the Java class name of the database driver package
Parameters:
  url - the contact string to database, or schema location
Parameters:
  info - additional parameters, usually username and password
Parameters:
  tables - is a set of all table names in the schema. Theexistence of all tables will be checked to verifythat the schema is active in the database. true if the connection succeeded, false otherwise. Usually,false is returned, if the any of the tables or sequences is missing.
See Also:   DatabaseDriver.connect(String,Properties,Set)
See Also:   org.griphyn.vdl.util.ChimeraProperties.getDatabaseDriverName
See Also:   org.griphyn.vdl.util.ChimeraProperties.getDatabaseURL
See Also:   org.griphyn.vdl.util.ChimeraProperties.getDatabaseDriverProperties if the driver is incapable of establishing a connection.




connect
abstract public boolean connect(String url, Properties info, Set tables) throws SQLException, ClassNotFoundException(Code)
Establish a connection to your database. The parameters will often be ignored or abused for different purposes on different backends. It is assumed that the connection is not in auto-commit mode, and explicit commits must be issued.
Parameters:
  url - the contact string to database, or schema location
Parameters:
  info - additional parameters, usually username and password
Parameters:
  tables - is a set of all table names in the schema. Theexistence of all tables will be checked to verifythat the schema is active in the database. true if the connection succeeded, false otherwise. Usually,false is returned, if the any of the tables or sequences is missing. if the driver is incapable of establishing a connection.



delete
public int delete(String table, Map columns) throws SQLException(Code)
Removes all rows that match the provided keyset from a table.
Parameters:
  table - is the name of the table to remove values from
Parameters:
  columns - is a set of column names and their associatedvalues to select the removed columns. The mapmay be null to remove all rows in a table. the number of rows removed. if something goes wrong while removing the values.



disconnect
public void disconnect() throws SQLException(Code)
Close an established database connection. if the driver threw up on the data.



driverMatch
public void driverMatch() throws SQLException(Code)
Determines, if the JDBC driver is the right one for the database we talk to. Throws an exception if not.



finalize
protected void finalize() throws Throwable(Code)
Closes an open connection to the database whenever this object is destroyed. This is still not foolproof.



getPreparedStatement
public PreparedStatement getPreparedStatement(String id) throws SQLException(Code)
Obtains a reference to a prepared statement to be used from the caller. This function will also reset the input values in the prepared statement.
Parameters:
  id - is the place of the statement to free up.
exception:
  SQLException - if the database does not like the disconnect.
See Also:   java.sql.PreparedStatement.clearParameters
See Also:   DatabaseDriver.addPreparedStatement(String,String)
See Also:   DatabaseDriver.removePreparedStatement(String)
See Also:   DatabaseDriver.cancelPreparedStatement(String)



getWarnings
public SQLWarning getWarnings() throws SQLException(Code)
Retrieves the first warning reported by calls on this Connection object. the first SQLWarning object or null if there are none
throws:
  SQLException - if a database access error occurs or thismethod is called on a closed connection
See Also:   java.sql.Connection.getWarnings



insert
public long insert(String table, Map keycolumns, Map columns) throws SQLException(Code)
Inserts a row in one given database table.
Parameters:
  table - is the name of the table to insert into.
Parameters:
  keycolumns - is a set of primary keys and their associated values.For special tables, the primary key set may be nullor empty (e.g. a table without primary keys).
Parameters:
  columns - is a set of regular keys and their associated values. the number of rows affected. if something goes wrong while inserting the values.



insertPreparedStatement
public boolean insertPreparedStatement(String id, String statement) throws SQLException(Code)
Inserts a new prepared statement into the list of prepared statements. If the id is already taken, an error will be printed and execution aborted.
Parameters:
  id - is the id into which to parse the statement
Parameters:
  statement - is the before-parsing statement string true, if the statement was parsed and added at the id,false, if the id was already taken. The statement is not parsedin that case.
exception:
  SQLException - may be thrown by parsing the statement.
See Also:   DatabaseDriver.addPreparedStatement(String,String)
See Also:   DatabaseDriver.getPreparedStatement(String)
See Also:   DatabaseDriver.cancelPreparedStatement(String)



loadDriver
public static DatabaseDriver loadDriver(String dbDriverName, String propertyPrefix, Object[] arguments) throws ClassNotFoundException, IOException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, SQLException(Code)
Instantiates the appropriate child according to property values. This method is a factory. Currently, drivers may be instantiated multiple times.


Parameters:
  dbDriverName - is the name of the class that conforms tothe DatabaseDriver API. This class will be dynamically loaded.The passed value should not be null.
Parameters:
  propertyPrefix - is the property prefix string to use.
Parameters:
  arguments - are arguments to the constructor of the driverto load. Please use "new Object[0]" for the argumentless defaultconstructor.
exception:
  ClassNotFoundException - if the driver for the databasecannot be loaded. You might want to check your CLASSPATH, too.
exception:
  NoSuchMethodException - if the driver's constructor interfacedoes not comply with the database driver API.
exception:
  InstantiationException - if the driver class is an abstractclass instead of a concrete implementation.
exception:
  IllegalAccessException - if the constructor for the driverclass it not publicly accessible to this package.
exception:
  InvocationTargetException - if the constructor of the driverthrows an exception while being dynamically loaded.
exception:
  SQLException - if the driver for the database can beloaded, but faults when initially accessing the database
See Also:   org.griphyn.vdl.util.ChimeraProperties.getDatabaseDriverName




loadDriver
public static DatabaseDriver loadDriver(String propertyPrefix) throws ClassNotFoundException, IOException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, SQLException(Code)
Convenience method instantiates the appropriate child according to property values. Effectively, the following abbreviation is called:
 loadDriver( null, propertyPrefix, new Object[0] );
 

Parameters:
  propertyPrefix - is the property prefix string to use.
exception:
  ClassNotFoundException - if the driver for the databasecannot be loaded. You might want to check your CLASSPATH, too.
exception:
  NoSuchMethodException - if the driver's constructor interfacedoes not comply with the database driver API.
exception:
  InstantiationException - if the driver class is an abstractclass instead of a concrete implementation.
exception:
  IllegalAccessException - if the constructor for the driverclass it not publicly accessible to this package.
exception:
  InvocationTargetException - if the constructor of the driverthrows an exception while being dynamically loaded.
exception:
  SQLException - if the driver for the database can beloaded, but faults when initially accessing the database
See Also:   DatabaseDriver.loadDriver(String,String,Object[])



preferString
abstract public boolean preferString()(Code)
Predicate to tell the schema, if using a string instead of number will result in the speedier index scans instead of sequential scans. PostGreSQL has this problem, but using strings in the place of integers may not be universally portable. true, if using strings instead of integers and bigintswill yield better performance.



quote
public String quote(String s)(Code)
Quotes a string that may contain special SQL characters.
Parameters:
  s - is the raw string. the quoted string, which may be just the input string.



removePreparedStatement
public void removePreparedStatement(String id) throws SQLException(Code)
Explicitely requests a prepared id to be destroyed and its resources freed. Multiple invocation for the same id are harmless.
Parameters:
  id - is the place of the statement to free up.
exception:
  SQLException - if the database does not like the disconnect.
See Also:   DatabaseDriver.addPreparedStatement(String,String)
See Also:   DatabaseDriver.getPreparedStatement(String)
See Also:   DatabaseDriver.cancelPreparedStatement(String)



rollback
public void rollback() throws SQLException(Code)
Rolls back the latest changes to the database. Some databases may be incapable of rolling back.
exception:
  SQLException - is propagated from the rollback operation.



select
public ResultSet select(List select, String table, Map where, String order) throws SQLException(Code)
Selects any rows in one or more colums from one or more tables restricted by some condition, possibly ordered.
Parameters:
  select - is the ordered set of column names to select, orsimply a one-value list with an asterisk.
Parameters:
  table - is the name of the table to select from.
Parameters:
  where - is a collection of column names and values they must equal.
Parameters:
  order - is an optional ordering string.



select
public ResultSet select(List select, String table, Map where, Map operator, String order) throws SQLException(Code)
Selects any rows in one or more colums from one or more tables restricted by some condition that allows operators. Permissable operators include =, <>, >, >=, <, <=, like, etc. possibly ordered.
Parameters:
  select - is the ordered set of column names to select, orsimply a one-value list with an asterisk.
Parameters:
  table - is the name of the table to select from.
Parameters:
  where - is a collection of column names and values
Parameters:
  operator - is a collection of column names and operatorsif no entry is found for the name, then use '=' as default
Parameters:
  order - is an optional ordering string.



sequence1
abstract public long sequence1(String name) throws SQLException(Code)
Obtains the next value from a sequence. JDBC drivers which allow explicit access to sequence generator will return a valid value in this function. All other JDBC drivers should return -1.
Parameters:
  name - is the name of the sequence. the next sequence number. if something goes wrong while fetching the new value.



sequence2
abstract public long sequence2(Statement s, String name, int pos) throws SQLException(Code)
Obtains the sequence value for the current statement. JDBC driver that permit insertion of NULL into auto-increment value should use this method to return the inserted ID value via the statements getGeneratedKeys(). Other JDBC drivers should treat return the parametric id.
Parameters:
  s - is a statment or prepared statement
Parameters:
  name - is the name of the sequence.
Parameters:
  pos - is the column number of the auto-increment column. the next sequence number. if something goes wrong while fetching the new value.



update
public int update(String table, Map keycolumns, Map columns) throws SQLException(Code)
Updates matching rows in one given database table.
Parameters:
  table - is the name of the table to insert into.
Parameters:
  keycolumns - is a set of primary keys and their associated values.For special tables, the primary key set may be nullor empty (e.g. a table without primary keys).
Parameters:
  columns - is a set of regular keys and their associated values. the number of rows affected if something goes wrong while updating the values.



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.