|
Project Wonder 5.0 | |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecter.extensions.jdbc.ERXJDBCUtilities
public class ERXJDBCUtilities
Nested Class Summary | |
---|---|
static class |
ERXJDBCUtilities.CopyTask
|
static interface |
ERXJDBCUtilities.IConnectionDelegate
IConnectionDelegate is like a closure for connection operations. |
static interface |
ERXJDBCUtilities.IResultSetDelegate
IResultSetDelegate is like a closure for ResultSet operations. |
Field Summary | |
---|---|
static org.apache.log4j.Logger |
log
|
static com.webobjects.foundation.NSTimestampFormatter |
TIMESTAMP_FORMATTER
|
Constructor Summary | |
---|---|
ERXJDBCUtilities()
|
Method Summary | |
---|---|
static void |
_copyDatabaseDefinedByEOModelAndConnectionDictionaryToDatabaseWithConnectionDictionary(com.webobjects.eoaccess.EOModelGroup modelGroup,
com.webobjects.foundation.NSDictionary sourceDict,
com.webobjects.foundation.NSDictionary destDict)
|
static void |
_copyDatabaseDefinedByEOModelAndConnectionDictionaryToDatabaseWithConnectionDictionary(com.webobjects.eoaccess.EOModel m,
com.webobjects.foundation.NSDictionary sourceDict,
com.webobjects.foundation.NSDictionary destDict)
Copies all rows from one database to another database. |
static com.webobjects.eoaccess.EOAdaptorChannel |
adaptorChannelWithUserAndPassword(com.webobjects.eoaccess.EOModel model,
java.lang.String userName,
java.lang.String password)
Returns an adaptor channel with the given username and password. |
static com.webobjects.eoaccess.EOAdaptorChannel |
adaptorChannelWithUserAndPassword(java.lang.String adaptorName,
com.webobjects.foundation.NSDictionary originalConnectionDictionary,
java.lang.String userName,
java.lang.String password)
Returns an adaptor channel with the given username and password. |
static void |
createTablesForEntities(com.webobjects.eoaccess.EOAdaptorChannel channel,
com.webobjects.foundation.NSArray<com.webobjects.eoaccess.EOEntity> entities)
Creates tables, primary keys, and foreign keys for the given list of entities. |
static void |
createTablesForModel(com.webobjects.eoaccess.EOAdaptorChannel channel,
com.webobjects.eoaccess.EOModel model)
Creates tables, primary keys, and foreign keys for the tables in the given model. |
static java.lang.String |
databaseProductName(com.webobjects.eoaccess.EOAdaptorChannel channel)
Returns the name of the database product for the given channel (handy when loading database-vendor-specific sql scripts in migrations). |
static java.lang.String |
databaseProductName(com.webobjects.eoaccess.EOModel model)
Returns the name of the database product for the given an eomodel (handy when loading database-vendor-specific sql scripts in migrations). |
static void |
dropTablesForEntities(com.webobjects.eoaccess.EOAdaptorChannel channel,
com.webobjects.foundation.NSArray<com.webobjects.eoaccess.EOEntity> entities,
boolean ignoreFailures)
Drops tables, primary keys, and foreign keys for the given list of entities. |
static void |
dropTablesForModel(com.webobjects.eoaccess.EOAdaptorChannel channel,
com.webobjects.eoaccess.EOModel model,
boolean ignoreFailures)
Drops tables, primary keys, and foreign keys for the tables in the given model. |
static void |
executeQuery(com.webobjects.eoaccess.EOAdaptorChannel adaptorChannel,
java.lang.String query,
ERXJDBCUtilities.IResultSetDelegate delegate)
Using the backing connection from the adaptor context, executes the given query and calls delegate.processResultSet(rs) once for the ResultSet. |
static int |
executeUpdate(com.webobjects.eoaccess.EOAdaptorChannel channel,
java.lang.String sql)
Shortcut to java.sql.Statement.executeUpdate(..) that operates on an EOAdaptorChannel. |
static int |
executeUpdate(com.webobjects.eoaccess.EOAdaptorChannel channel,
java.lang.String sql,
boolean autoCommit)
Shortcut to java.sql.Statement.executeUpdate(..) that operates on an EOAdaptorChannel. |
static int |
executeUpdateScript(com.webobjects.eoaccess.EOAdaptorChannel channel,
com.webobjects.foundation.NSArray<java.lang.String> sqlStatements)
Splits the given sqlscript and executes each of the statements in a single transaction |
static int |
executeUpdateScript(com.webobjects.eoaccess.EOAdaptorChannel channel,
com.webobjects.foundation.NSArray<java.lang.String> sqlStatements,
boolean ignoreFailures)
Splits the given sqlscript and executes each of the statements in a single transaction |
static int |
executeUpdateScript(com.webobjects.eoaccess.EOAdaptorChannel channel,
java.lang.String sqlScript)
Splits the given sqlscript and executes each of the statements in a single transaction |
static int |
executeUpdateScript(com.webobjects.eoaccess.EOAdaptorChannel channel,
java.lang.String sqlScript,
boolean ignoreFailures)
Splits the given sqlscript and executes each of the statements in a single transaction |
static int |
executeUpdateScriptFromResourceNamed(com.webobjects.eoaccess.EOAdaptorChannel channel,
java.lang.String resourceName,
java.lang.String frameworkName)
Executes a SQL script that is stored as a resource. |
static int |
executeUpdateScriptIgnoringErrors(com.webobjects.eoaccess.EOAdaptorChannel channel,
java.lang.String script)
Deprecated. use executeUpdateScript with the boolean param |
static javax.sql.rowset.CachedRowSet |
fetchRowSet(com.webobjects.eoaccess.EOAdaptorChannel adaptorChannel,
java.lang.String query)
Using the backing connection from the adaptor context, executes the given query and returns a CachedRowSet of the results. |
static java.lang.String |
jdbcTimestamp(com.webobjects.foundation.NSTimestamp t)
|
static void |
processConnection(com.webobjects.eoaccess.EOAdaptorChannel adaptorChannel,
ERXJDBCUtilities.IConnectionDelegate delegate)
Using the backing connection from the adaptor context, executes the given query and calls delegate.processConnection(conn) for the Connection. |
static void |
processResultSetRows(com.webobjects.eoaccess.EOAdaptorChannel adaptorChannel,
java.lang.String query,
ERXJDBCUtilities.IResultSetDelegate delegate)
Using the backing connection from the adaptor context, executes the given query and calls processor.process(rs) for each row of the ResultSet. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final org.apache.log4j.Logger log
public static final com.webobjects.foundation.NSTimestampFormatter TIMESTAMP_FORMATTER
Constructor Detail |
---|
public ERXJDBCUtilities()
Method Detail |
---|
public static java.lang.String jdbcTimestamp(com.webobjects.foundation.NSTimestamp t)
public static void _copyDatabaseDefinedByEOModelAndConnectionDictionaryToDatabaseWithConnectionDictionary(com.webobjects.eoaccess.EOModel m, com.webobjects.foundation.NSDictionary sourceDict, com.webobjects.foundation.NSDictionary destDict)
NSMutableDictionary sourceDict = new NSMutableDictionary(); sourceDict.setObjectForKey("YourPassword", "password"); sourceDict.setObjectForKey("YourUserName", "username"); sourceDict.setObjectForKey("jdbc:FrontBase://127.0.0.1/YourSourceDatabase", "URL"); sourceDict.setObjectForKey("com.frontbase.jdbc.FBJDriver", "driver"); sourceDict.setObjectForKey(Boolean.FALSE.toString(), "autoCommit"); sourceDict.setObjectForKey(Boolean.TRUE.toString(), "readOnly"); sourceDict.setObjectForKey(Boolean.TRUE.toString(), "quote"); NSMutableDictionary destDict = sourceDict.mutableClone(); destDict.setObjectForKey("jdbc:postgresql://localhost/YourDestinationDatabase", "URL"); destDict.setObjectForKey("YourPassword", "password"); destDict.setObjectForKey("YourUserName", "username"); destDict.setObjectForKey("org.postgresql.Driver", "driver"); destDict.setObjectForKey(Boolean.FALSE.toString(), "autoCommit"); destDict.setObjectForKey(Boolean.FALSE.toString(), "readOnly"); destDict.setObjectForKey(Boolean.FALSE.toString(), "quote"); EOModel model = EOModelGroup.defaultGroup().modelNamed("YourModelName"); ERXJDBCUtilities._copyDatabaseDefinedByEOModelAndConnectionDictionaryToDatabaseWithConnectionDictionary(model, sourceDict, destDict);
m
- the model that defines the database to copysourceDict
- a NSDictionary containing the following keys for the source
database:
jdbc:FrontBase://host/database
, for PostgreSQL
its jdbc:postgresql://host/database
com.frontbase.jdbc.FBJDriver
, for
PostgreSQL its org.postgresql.Driver
destDict
- same as sourceDict just used for the destination database.public static void _copyDatabaseDefinedByEOModelAndConnectionDictionaryToDatabaseWithConnectionDictionary(com.webobjects.eoaccess.EOModelGroup modelGroup, com.webobjects.foundation.NSDictionary sourceDict, com.webobjects.foundation.NSDictionary destDict)
modelGroup
- the model group to copysourceDict
- the source connection dictionarydestDict
- the destination connection dictionaryERXJDBCUtilities._copyDatabaseDefinedByEOModelAndConnectionDictionaryToDatabaseWithConnectionDictionary(EOModel, NSDictionary, NSDictionary)
public static com.webobjects.eoaccess.EOAdaptorChannel adaptorChannelWithUserAndPassword(com.webobjects.eoaccess.EOModel model, java.lang.String userName, java.lang.String password)
model
- the model to base this connection off ofuserName
- the new usernamepassword
- the new password
public static com.webobjects.eoaccess.EOAdaptorChannel adaptorChannelWithUserAndPassword(java.lang.String adaptorName, com.webobjects.foundation.NSDictionary originalConnectionDictionary, java.lang.String userName, java.lang.String password)
adaptorName
- the name of the adaptor to useroriginalConnectionDictionary
- the original connection dictionaryuserName
- the new usernamepassword
- the new password
public static int executeUpdate(com.webobjects.eoaccess.EOAdaptorChannel channel, java.lang.String sql) throws java.sql.SQLException
channel
- the JDBCChannel to work withsql
- the sql to execute
java.sql.SQLException
- if there is a problempublic static int executeUpdate(com.webobjects.eoaccess.EOAdaptorChannel channel, java.lang.String sql, boolean autoCommit) throws java.sql.SQLException
channel
- the JDBCChannel to work withsql
- the sql to executeautoCommit
- if true, autocommit the connection after executing
java.sql.SQLException
- if there is a problempublic static int executeUpdateScript(com.webobjects.eoaccess.EOAdaptorChannel channel, java.lang.String sqlScript) throws java.sql.SQLException
channel
- the JDBCChannel to work withsqlScript
- the sql script to execute
java.sql.SQLException
- if there is a problempublic static int executeUpdateScript(com.webobjects.eoaccess.EOAdaptorChannel channel, java.lang.String sqlScript, boolean ignoreFailures) throws java.sql.SQLException
channel
- the JDBCChannel to work withsqlScript
- the sql script to executeignoreFailures
- if true, failures in a particular statement are ignored
java.sql.SQLException
- if there is a problempublic static int executeUpdateScript(com.webobjects.eoaccess.EOAdaptorChannel channel, com.webobjects.foundation.NSArray<java.lang.String> sqlStatements) throws java.sql.SQLException
channel
- the JDBCChannel to work withsqlStatements
- the array of sql scripts to execute
java.sql.SQLException
- if there is a problempublic static int executeUpdateScript(com.webobjects.eoaccess.EOAdaptorChannel channel, com.webobjects.foundation.NSArray<java.lang.String> sqlStatements, boolean ignoreFailures) throws java.sql.SQLException
channel
- the JDBCChannel to work withsqlStatements
- the array of sql scripts to executeignoreFailures
- if true, failures in a particular statement are ignored
java.sql.SQLException
- if there is a problempublic static int executeUpdateScriptIgnoringErrors(com.webobjects.eoaccess.EOAdaptorChannel channel, java.lang.String script) throws java.sql.SQLException
channel
- the JDBCChannel to work withscript
- the array of sql scripts to execute
java.sql.SQLException
- if there is a problempublic static int executeUpdateScriptFromResourceNamed(com.webobjects.eoaccess.EOAdaptorChannel channel, java.lang.String resourceName, java.lang.String frameworkName) throws java.sql.SQLException, java.io.IOException
channel
- the channel to execute the scripts withinresourceName
- the name of the SQL script resourceframeworkName
- the name of the framework that contains the resource
java.sql.SQLException
- if a SQL error occurs
java.io.IOException
- if an error occurs reading the scriptpublic static void dropTablesForModel(com.webobjects.eoaccess.EOAdaptorChannel channel, com.webobjects.eoaccess.EOModel model, boolean ignoreFailures) throws java.sql.SQLException
channel
- the channel to use for executionmodel
- the model to drop tables forignoreFailures
- if true, failures in a particular statement are ignored
java.sql.SQLException
- if something failspublic static void dropTablesForEntities(com.webobjects.eoaccess.EOAdaptorChannel channel, com.webobjects.foundation.NSArray<com.webobjects.eoaccess.EOEntity> entities, boolean ignoreFailures) throws java.sql.SQLException
channel
- the channel to use for executionentities
- the entities to drop tables forignoreFailures
- if true, failures in a particular statement are ignored
java.sql.SQLException
- if something failspublic static void createTablesForModel(com.webobjects.eoaccess.EOAdaptorChannel channel, com.webobjects.eoaccess.EOModel model) throws java.sql.SQLException
channel
- the channel to use for executionmodel
- the model to create tables for
java.sql.SQLException
- if something failspublic static void createTablesForEntities(com.webobjects.eoaccess.EOAdaptorChannel channel, com.webobjects.foundation.NSArray<com.webobjects.eoaccess.EOEntity> entities) throws java.sql.SQLException
channel
- the channel to use for executionentities
- the entities to create tables for
java.sql.SQLException
- if something failspublic static java.lang.String databaseProductName(com.webobjects.eoaccess.EOAdaptorChannel channel)
channel
- the channel
public static java.lang.String databaseProductName(com.webobjects.eoaccess.EOModel model)
model
- the EOModel
public static void processConnection(com.webobjects.eoaccess.EOAdaptorChannel adaptorChannel, ERXJDBCUtilities.IConnectionDelegate delegate) throws java.lang.Exception
adaptorChannel
- the adaptor channeldelegate
- the connection delegate
java.lang.Exception
- if something goes wrongpublic static void executeQuery(com.webobjects.eoaccess.EOAdaptorChannel adaptorChannel, java.lang.String query, ERXJDBCUtilities.IResultSetDelegate delegate) throws java.lang.Exception
adaptorChannel
- the adaptor channelquery
- the query to executedelegate
- the processor delegate
java.lang.Exception
- if something goes wrongpublic static void processResultSetRows(com.webobjects.eoaccess.EOAdaptorChannel adaptorChannel, java.lang.String query, ERXJDBCUtilities.IResultSetDelegate delegate) throws java.lang.Exception
adaptorChannel
- the adaptor channelquery
- the query to executedelegate
- the processor delegate
java.lang.Exception
- if something goes wrongpublic static javax.sql.rowset.CachedRowSet fetchRowSet(com.webobjects.eoaccess.EOAdaptorChannel adaptorChannel, java.lang.String query) throws java.lang.Exception
adaptorChannel
- the adaptor channelquery
- the query to execute
java.lang.Exception
- if something goes wrong
|
Last updated: Tue, Feb 21, 2017 05:45 PM CET | |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |