
Classes | |
| class | CopyTask |
| interface | IConnectionDelegate |
| interface | IResultSetDelegate |
Static Public Member Functions | |
| static void | _copyDatabaseDefinedByEOModelAndConnectionDictionaryToDatabaseWithConnectionDictionary (EOModelGroup modelGroup, NSDictionary sourceDict, NSDictionary destDict) |
| static void | _copyDatabaseDefinedByEOModelAndConnectionDictionaryToDatabaseWithConnectionDictionary (EOModel m, NSDictionary sourceDict, NSDictionary destDict) |
| static EOAdaptorChannel | adaptorChannelWithUserAndPassword (String adaptorName, NSDictionary originalConnectionDictionary, String userName, String password) |
| static EOAdaptorChannel | adaptorChannelWithUserAndPassword (EOModel model, String userName, String password) |
| static void | createTablesForEntities (EOAdaptorChannel channel, NSArray< EOEntity > entities) throws SQLException |
| static void | createTablesForModel (EOAdaptorChannel channel, EOModel model) throws SQLException |
| static String | databaseProductName (EOModel model) |
| static String | databaseProductName (EOAdaptorChannel channel) |
| static void | dropTablesForEntities (EOAdaptorChannel channel, NSArray< EOEntity > entities, boolean ignoreFailures) throws SQLException |
| static void | dropTablesForModel (EOAdaptorChannel channel, EOModel model, boolean ignoreFailures) throws SQLException |
| static void | executeQuery (EOAdaptorChannel adaptorChannel, final String query, final IResultSetDelegate delegate) throws Exception |
| static int | executeUpdate (EOAdaptorChannel channel, String sql, boolean autoCommit) throws SQLException |
| static int | executeUpdate (EOAdaptorChannel channel, String sql) throws SQLException |
| static int | executeUpdateScript (EOAdaptorChannel channel, NSArray< String > sqlStatements, boolean ignoreFailures) throws SQLException |
| static int | executeUpdateScript (EOAdaptorChannel channel, NSArray< String > sqlStatements) throws SQLException |
| static int | executeUpdateScript (EOAdaptorChannel channel, String sqlScript, boolean ignoreFailures) throws SQLException |
| static int | executeUpdateScript (EOAdaptorChannel channel, String sqlScript) throws SQLException |
| static int | executeUpdateScriptFromResourceNamed (EOAdaptorChannel channel, String resourceName, String frameworkName) throws SQLException, IOException |
| static int | executeUpdateScriptIgnoringErrors (EOAdaptorChannel channel, String script) throws SQLException |
| static CachedRowSet | fetchRowSet (EOAdaptorChannel adaptorChannel, String query) throws Exception |
| static String | jdbcTimestamp (NSTimestamp t) |
| static void | processConnection (EOAdaptorChannel adaptorChannel, IConnectionDelegate delegate) throws Exception |
| static void | processResultSetRows (EOAdaptorChannel adaptorChannel, String query, final IResultSetDelegate delegate) throws Exception |
Static Public Attributes | |
| static final Logger | log = Logger.getLogger(ERXJDBCUtilities.class) |
| static final NSTimestampFormatter | TIMESTAMP_FORMATTER = new NSTimestampFormatter("%Y-%m-%d %H:%M:%S.%F") |
| static void _copyDatabaseDefinedByEOModelAndConnectionDictionaryToDatabaseWithConnectionDictionary | ( | EOModelGroup | modelGroup, | |
| NSDictionary | sourceDict, | |||
| NSDictionary | destDict | |||
| ) | [static] |
| modelGroup | the model group to copy | |
| sourceDict | the source connection dictionary | |
| destDict | the destination connection dictionary |
| static void _copyDatabaseDefinedByEOModelAndConnectionDictionaryToDatabaseWithConnectionDictionary | ( | EOModel | m, | |
| NSDictionary | sourceDict, | |||
| NSDictionary | destDict | |||
| ) | [static] |
Copies all rows from one database to another database. The tables must exist before calling this method.
Example:
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 copy | |
| sourceDict | a NSDictionary containing the following keys for the source database:
| |
| destDict | same as sourceDict just used for the destination database. |
| static EOAdaptorChannel adaptorChannelWithUserAndPassword | ( | String | adaptorName, | |
| NSDictionary | originalConnectionDictionary, | |||
| String | userName, | |||
| String | password | |||
| ) | [static] |
Returns an adaptor channel with the given username and password.
| adaptorName | the name of the adaptor to user | |
| originalConnectionDictionary | the original connection dictionary | |
| userName | the new username | |
| password | the new password |
| static EOAdaptorChannel adaptorChannelWithUserAndPassword | ( | EOModel | model, | |
| String | userName, | |||
| String | password | |||
| ) | [static] |
Returns an adaptor channel with the given username and password.
| model | the model to base this connection off of | |
| userName | the new username | |
| password | the new password |
| static void createTablesForEntities | ( | EOAdaptorChannel | channel, | |
| NSArray< EOEntity > | entities | |||
| ) | throws SQLException [static] |
Creates tables, primary keys, and foreign keys for the given list of entities. This is useful in your Migration #0 class.
| channel | the channel to use for execution | |
| entities | the entities to create tables for |
| SQLException | if something fails |
| static void createTablesForModel | ( | EOAdaptorChannel | channel, | |
| EOModel | model | |||
| ) | throws SQLException [static] |
Creates tables, primary keys, and foreign keys for the tables in the given model. This is useful in your Migration #0 class.
| channel | the channel to use for execution | |
| model | the model to create tables for |
| SQLException | if something fails |
| static String databaseProductName | ( | EOModel | model | ) | [static] |
Returns the name of the database product for the given an eomodel (handy when loading database-vendor-specific sql scripts in migrations).
| model | the EOModel |
| static String databaseProductName | ( | EOAdaptorChannel | channel | ) | [static] |
Returns the name of the database product for the given channel (handy when loading database-vendor-specific sql scripts in migrations).
| channel | the channel |
| static void dropTablesForEntities | ( | EOAdaptorChannel | channel, | |
| NSArray< EOEntity > | entities, | |||
| boolean | ignoreFailures | |||
| ) | throws SQLException [static] |
Drops tables, primary keys, and foreign keys for the given list of entities. This is useful in your Migration #0 class.
| channel | the channel to use for execution | |
| entities | the entities to drop tables for | |
| ignoreFailures | if true, failures in a particular statement are ignored |
| SQLException | if something fails |
| static void dropTablesForModel | ( | EOAdaptorChannel | channel, | |
| EOModel | model, | |||
| boolean | ignoreFailures | |||
| ) | throws SQLException [static] |
Drops tables, primary keys, and foreign keys for the tables in the given model.
| channel | the channel to use for execution | |
| model | the model to drop tables for | |
| ignoreFailures | if true, failures in a particular statement are ignored |
| SQLException | if something fails |
| static void executeQuery | ( | EOAdaptorChannel | adaptorChannel, | |
| final String | query, | |||
| final IResultSetDelegate | delegate | |||
| ) | throws Exception [static] |
Using the backing connection from the adaptor context, executes the given query and calls delegate.processResultSet(rs) once for the ResultSet. This handles properly closing all the underlying JDBC resources.
| adaptorChannel | the adaptor channel | |
| query | the query to execute | |
| delegate | the processor delegate |
| Exception | if something goes wrong |
| static int executeUpdate | ( | EOAdaptorChannel | channel, | |
| String | sql, | |||
| boolean | autoCommit | |||
| ) | throws SQLException [static] |
Shortcut to java.sql.Statement.executeUpdate(..) that operates on an EOAdaptorChannel. and optionally commits.
| channel | the JDBCChannel to work with | |
| sql | the sql to execute | |
| autoCommit | if true, autocommit the connection after executing |
| SQLException | if there is a problem |
| static int executeUpdate | ( | EOAdaptorChannel | channel, | |
| String | sql | |||
| ) | throws SQLException [static] |
Shortcut to java.sql.Statement.executeUpdate(..) that operates on an EOAdaptorChannel.
| channel | the JDBCChannel to work with | |
| sql | the sql to execute |
| SQLException | if there is a problem |
| static int executeUpdateScript | ( | EOAdaptorChannel | channel, | |
| NSArray< String > | sqlStatements, | |||
| boolean | ignoreFailures | |||
| ) | throws SQLException [static] |
Splits the given sqlscript and executes each of the statements in a single transaction
| channel | the JDBCChannel to work with | |
| sqlStatements | the array of sql scripts to execute | |
| ignoreFailures | if true, failures in a particular statement are ignored |
| SQLException | if there is a problem |
| static int executeUpdateScript | ( | EOAdaptorChannel | channel, | |
| NSArray< String > | sqlStatements | |||
| ) | throws SQLException [static] |
Splits the given sqlscript and executes each of the statements in a single transaction
| channel | the JDBCChannel to work with | |
| sqlStatements | the array of sql scripts to execute |
| SQLException | if there is a problem |
| static int executeUpdateScript | ( | EOAdaptorChannel | channel, | |
| String | sqlScript, | |||
| boolean | ignoreFailures | |||
| ) | throws SQLException [static] |
Splits the given sqlscript and executes each of the statements in a single transaction
| channel | the JDBCChannel to work with | |
| sqlScript | the sql script to execute | |
| ignoreFailures | if true, failures in a particular statement are ignored |
| SQLException | if there is a problem |
| static int executeUpdateScript | ( | EOAdaptorChannel | channel, | |
| String | sqlScript | |||
| ) | throws SQLException [static] |
Splits the given sqlscript and executes each of the statements in a single transaction
| channel | the JDBCChannel to work with | |
| sqlScript | the sql script to execute |
| SQLException | if there is a problem |
| static int executeUpdateScriptFromResourceNamed | ( | EOAdaptorChannel | channel, | |
| String | resourceName, | |||
| String | frameworkName | |||
| ) | throws SQLException, IOException [static] |
Executes a SQL script that is stored as a resource.
| channel | the channel to execute the scripts within | |
| resourceName | the name of the SQL script resource | |
| frameworkName | the name of the framework that contains the resource |
| SQLException | if a SQL error occurs | |
| IOException | if an error occurs reading the script |
| static int executeUpdateScriptIgnoringErrors | ( | EOAdaptorChannel | channel, | |
| String | script | |||
| ) | throws SQLException [static] |
Runs a given sql script and executes each of the statements in a one transaction.
| channel | the JDBCChannel to work with | |
| script | the array of sql scripts to execute |
| SQLException | if there is a problem |
| static CachedRowSet fetchRowSet | ( | EOAdaptorChannel | adaptorChannel, | |
| String | query | |||
| ) | throws Exception [static] |
Using the backing connection from the adaptor context, executes the given query and returns a CachedRowSet of the results. This can be useful for more complicated migrations. This handles properly closing all the underlying JDBC resources.
| adaptorChannel | the adaptor channel | |
| query | the query to execute |
| Exception | if something goes wrong |
| static String jdbcTimestamp | ( | NSTimestamp | t | ) | [static] |
| static void processConnection | ( | EOAdaptorChannel | adaptorChannel, | |
| IConnectionDelegate | delegate | |||
| ) | throws Exception [static] |
Using the backing connection from the adaptor context, executes the given query and calls delegate.processConnection(conn) for the Connection. This handles properly closing all the underlying JDBC resources.
| adaptorChannel | the adaptor channel | |
| delegate | the connection delegate |
| Exception | if something goes wrong |
| static void processResultSetRows | ( | EOAdaptorChannel | adaptorChannel, | |
| String | query, | |||
| final IResultSetDelegate | delegate | |||
| ) | throws Exception [static] |
Using the backing connection from the adaptor context, executes the given query and calls processor.process(rs) for each row of the ResultSet. This handles properly closing all the underlying JDBC resources.
| adaptorChannel | the adaptor channel | |
| query | the query to execute | |
| delegate | the processor delegate |
| Exception | if something goes wrong |
final Logger log = Logger.getLogger(ERXJDBCUtilities.class) [static] |
final NSTimestampFormatter TIMESTAMP_FORMATTER = new NSTimestampFormatter("%Y-%m-%d %H:%M:%S.%F") [static] |
1.5.8