com.synex.xml.db
Class DBManagerImpl

java.lang.Object
  |
  +--com.synex.xml.db.DBManagerImpl
All Implemented Interfaces:
DBManager

public class DBManagerImpl
extends java.lang.Object
implements DBManager

Default implementation of the DBManager interface. This class provides default implementations for all of the callbacks in the core database manager class DBManager.


Constructor Summary
DBManagerImpl()
          Creates new DBManagerImpl
 
Method Summary
 java.util.Map addRow(java.lang.String tableName, java.util.Map ids, java.util.Map fields)
          Adds a new record.
 void close()
          Releases a database and JDBC resources immediately instead of waiting for them to be automatically released.
protected  java.lang.String createID(java.lang.String tableName, java.lang.String keyName)
          Creates a new primary key
 void deleteRow(java.lang.String tableName, java.util.Map ids, java.util.Map fields)
          Deletes an existed record.
 void flush()
          Flushes this database connection.
 void open(java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String password)
          Attempts to establish a connection to the given database URL.
protected  void setParameter(java.sql.PreparedStatement pstmt, int index, int type, java.lang.String value)
          Invokes the proper setXXX method
 void updateRow(java.lang.String tableName, java.util.Map ids, java.util.Map fields)
          Updates an existed record.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBManagerImpl

public DBManagerImpl()
Creates new DBManagerImpl
Method Detail

open

public void open(java.lang.String driver,
                 java.lang.String url,
                 java.lang.String user,
                 java.lang.String password)
          throws DBManagerException
Attempts to establish a connection to the given database URL.
Specified by:
open in interface DBManager
Parameters:
driver - the new JDBC Driver
url - a database url of the form jdbc:subprotocol:subname
user - the database user on whose behalf the connection is being made
password - the user's password
Throws:
DBManagerException - Any database exception, possibly wrapping another exception.

flush

public void flush()
           throws DBManagerException
Flushes this database connection.
Specified by:
flush in interface DBManager
Throws:
DBManagerException - Any database exception, possibly wrapping another exception.

close

public void close()
           throws DBManagerException
Releases a database and JDBC resources immediately instead of waiting for them to be automatically released.
Specified by:
close in interface DBManager
Throws:
DBManagerException - Any database exception, possibly wrapping another exception.

addRow

public java.util.Map addRow(java.lang.String tableName,
                                  java.util.Map ids,
                                  java.util.Map fields)
                           throws DBManagerException
Adds a new record.
Specified by:
addRow in interface DBManager
Parameters:
ids - the list of primary keys (name/value pairs)
fields - the list of fields (name/value pairs)
tableName - the name of the table
Returns:
Map the primary keys
Throws:
DBManagerException - Any database exception, possibly wrapping another exception.

updateRow

public void updateRow(java.lang.String tableName,
                      java.util.Map ids,
                      java.util.Map fields)
               throws DBManagerException
Updates an existed record.
Specified by:
updateRow in interface DBManager
Parameters:
ids - the list of primary keys (name/value pairs)
fields - the list of fields (name/value pairs)
tableName - the name of the table
Throws:
DBManagerException - Any database exception, possibly wrapping another exception.

deleteRow

public void deleteRow(java.lang.String tableName,
                      java.util.Map ids,
                      java.util.Map fields)
               throws DBManagerException
Deletes an existed record.
Specified by:
deleteRow in interface DBManager
Parameters:
tableName - the name of the table
ids - the list of primary keys (name/value pairs)
fields - the list of fields (name/value pairs)
Throws:
DBManagerException - Any database exception, possibly wrapping another exception.

createID

protected java.lang.String createID(java.lang.String tableName,
                                    java.lang.String keyName)
                             throws java.sql.SQLException
Creates a new primary key
Parameters:
tableName - the name of the table
keyName - the name of the primary key
Returns:
the primary key
Throws:
SQLException - if a database access error occurs

setParameter

protected void setParameter(java.sql.PreparedStatement pstmt,
                            int index,
                            int type,
                            java.lang.String value)
                     throws java.sql.SQLException
Invokes the proper setXXX method
Parameters:
pstmt - an object that represents a precompiled SQL statement
index - the first parameter is 1, the second is 2, ...
type - JDBC type
value - the parameter value
Throws:
SQLException - if a database access error occurs


Submit a bug or feature
For further API reference and developer documentation, see XML Bulk Loader Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Copyright 2002 Sergey Yakovlev, All Rights Reserved.