|
Project Wonder 5.0.0.8794 | |||||||||
| 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 Logger |
log
|
static NSTimestampFormatter |
TIMESTAMP_FORMATTER
|
| Constructor Summary | |
|---|---|
ERXJDBCUtilities()
|
|
| Method Summary | |
|---|---|
static void |
_copyDatabaseDefinedByEOModelAndConnectionDictionaryToDatabaseWithConnectionDictionary(EOModelGroup modelGroup,
NSDictionary sourceDict,
NSDictionary destDict)
|
static void |
_copyDatabaseDefinedByEOModelAndConnectionDictionaryToDatabaseWithConnectionDictionary(EOModel m,
NSDictionary sourceDict,
NSDictionary destDict)
Copies all rows from one database to another database. |
static EOAdaptorChannel |
adaptorChannelWithUserAndPassword(EOModel model,
String userName,
String password)
Returns an adaptor channel with the given username and password. |
static EOAdaptorChannel |
adaptorChannelWithUserAndPassword(String adaptorName,
NSDictionary originalConnectionDictionary,
String userName,
String password)
Returns an adaptor channel with the given username and password. |
static void |
createTablesForEntities(EOAdaptorChannel channel,
NSArray<EOEntity> entities)
Creates tables, primary keys, and foreign keys for the given list of entities. |
static void |
createTablesForModel(EOAdaptorChannel channel,
EOModel model)
Creates tables, primary keys, and foreign keys for the tables in the given model. |
static String |
databaseProductName(EOAdaptorChannel channel)
Returns the name of the database product for the given channel (handy when loading database-vendor-specific sql scripts in migrations). |
static String |
databaseProductName(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(EOAdaptorChannel channel,
NSArray<EOEntity> entities,
boolean ignoreFailures)
Drops tables, primary keys, and foreign keys for the given list of entities. |
static void |
dropTablesForModel(EOAdaptorChannel channel,
EOModel model,
boolean ignoreFailures)
Drops tables, primary keys, and foreign keys for the tables in the given model. |
static void |
executeQuery(EOAdaptorChannel adaptorChannel,
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(EOAdaptorChannel channel,
String sql)
Shortcut to java.sql.Statement.executeUpdate(..) that operates on an EOAdaptorChannel. |
static int |
executeUpdate(EOAdaptorChannel channel,
String sql,
boolean autoCommit)
Shortcut to java.sql.Statement.executeUpdate(..) that operates on an EOAdaptorChannel. |
static int |
executeUpdateScript(EOAdaptorChannel channel,
NSArray<String> sqlStatements)
Splits the given sqlscript and executes each of the statements in a single transaction |
static int |
executeUpdateScript(EOAdaptorChannel channel,
NSArray<String> sqlStatements,
boolean ignoreFailures)
Splits the given sqlscript and executes each of the statements in a single transaction |
static int |
executeUpdateScript(EOAdaptorChannel channel,
String sqlScript)
Splits the given sqlscript and executes each of the statements in a single transaction |
static int |
executeUpdateScript(EOAdaptorChannel channel,
String sqlScript,
boolean ignoreFailures)
Splits the given sqlscript and executes each of the statements in a single transaction |
static int |
executeUpdateScriptFromResourceNamed(EOAdaptorChannel channel,
String resourceName,
String frameworkName)
Executes a SQL script that is stored as a resource. |
static int |
executeUpdateScriptIgnoringErrors(EOAdaptorChannel channel,
String script)
Deprecated. use executeUpdateScript with the boolean param |
static javax.sql.rowset.CachedRowSet |
fetchRowSet(EOAdaptorChannel adaptorChannel,
String query)
Using the backing connection from the adaptor context, executes the given query and returns a CachedRowSet of the results. |
static String |
jdbcTimestamp(NSTimestamp t)
|
static void |
processConnection(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(EOAdaptorChannel adaptorChannel,
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 Logger log
public static NSTimestampFormatter TIMESTAMP_FORMATTER
| Constructor Detail |
|---|
public ERXJDBCUtilities()
| Method Detail |
|---|
public static String jdbcTimestamp(NSTimestamp t)
public static void _copyDatabaseDefinedByEOModelAndConnectionDictionaryToDatabaseWithConnectionDictionary(EOModel m,
NSDictionary sourceDict,
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(EOModelGroup modelGroup,
NSDictionary sourceDict,
NSDictionary destDict)
modelGroup - the model group to copysourceDict - the source connection dictionarydestDict - the destination connection dictionaryERXJDBCUtilities._copyDatabaseDefinedByEOModelAndConnectionDictionaryToDatabaseWithConnectionDictionary(EOModel, NSDictionary, NSDictionary)
public static EOAdaptorChannel adaptorChannelWithUserAndPassword(EOModel model,
String userName,
String password)
model - the model to base this connection off ofuserName - the new usernamepassword - the new password
public static EOAdaptorChannel adaptorChannelWithUserAndPassword(String adaptorName,
NSDictionary originalConnectionDictionary,
String userName,
String password)
adaptorName - the name of the adaptor to useroriginalConnectionDictionary - the original connection dictionaryuserName - the new usernamepassword - the new password
public static int executeUpdate(EOAdaptorChannel channel,
String sql)
throws SQLException
channel - the JDBCChannel to work withsql - the sql to execute
SQLException - if there is a problem
public static int executeUpdate(EOAdaptorChannel channel,
String sql,
boolean autoCommit)
throws SQLException
channel - the JDBCChannel to work withsql - the sql to executeautoCommit - if true, autocommit the connection after executing
SQLException - if there is a problem
public static int executeUpdateScript(EOAdaptorChannel channel,
String sqlScript)
throws SQLException
channel - the JDBCChannel to work withsqlScript - the sql script to execute
SQLException - if there is a problem
public static int executeUpdateScript(EOAdaptorChannel channel,
String sqlScript,
boolean ignoreFailures)
throws SQLException
channel - the JDBCChannel to work withsqlScript - the sql script to executeignoreFailures - if true, failures in a particular statement are ignored
SQLException - if there is a problem
public static int executeUpdateScript(EOAdaptorChannel channel,
NSArray<String> sqlStatements)
throws SQLException
channel - the JDBCChannel to work withsqlStatements - the array of sql scripts to execute
SQLException - if there is a problem
public static int executeUpdateScript(EOAdaptorChannel channel,
NSArray<String> sqlStatements,
boolean ignoreFailures)
throws SQLException
channel - the JDBCChannel to work withsqlStatements - the array of sql scripts to executeignoreFailures - if true, failures in a particular statement are ignored
SQLException - if there is a problem
public static int executeUpdateScriptIgnoringErrors(EOAdaptorChannel channel,
String script)
throws SQLException
channel - the JDBCChannel to work withscript - the array of sql scripts to execute
SQLException - if there is a problem
public static int executeUpdateScriptFromResourceNamed(EOAdaptorChannel channel,
String resourceName,
String frameworkName)
throws SQLException,
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
SQLException - if a SQL error occurs
IOException - if an error occurs reading the script
public static void dropTablesForModel(EOAdaptorChannel channel,
EOModel model,
boolean ignoreFailures)
throws SQLException
channel - the channel to use for executionmodel - the model to drop tables forignoreFailures - if true, failures in a particular statement are ignored
SQLException - if something fails
public static void dropTablesForEntities(EOAdaptorChannel channel,
NSArray<EOEntity> entities,
boolean ignoreFailures)
throws SQLException
channel - the channel to use for executionentities - the entities to drop tables forignoreFailures - if true, failures in a particular statement are ignored
SQLException - if something fails
public static void createTablesForModel(EOAdaptorChannel channel,
EOModel model)
throws SQLException
channel - the channel to use for executionmodel - the model to create tables for
SQLException - if something fails
public static void createTablesForEntities(EOAdaptorChannel channel,
NSArray<EOEntity> entities)
throws SQLException
channel - the channel to use for executionentities - the entities to create tables for
SQLException - if something failspublic static String databaseProductName(EOAdaptorChannel channel)
channel - the channel
public static String databaseProductName(EOModel model)
model - the EOModel
public static void processConnection(EOAdaptorChannel adaptorChannel,
ERXJDBCUtilities.IConnectionDelegate delegate)
throws Exception
adaptorChannel - the adaptor channeldelegate - the connection delegate
Exception - if something goes wrong
public static void executeQuery(EOAdaptorChannel adaptorChannel,
String query,
ERXJDBCUtilities.IResultSetDelegate delegate)
throws Exception
adaptorChannel - the adaptor channelquery - the query to executedelegate - the processor delegate
Exception - if something goes wrong
public static void processResultSetRows(EOAdaptorChannel adaptorChannel,
String query,
ERXJDBCUtilities.IResultSetDelegate delegate)
throws Exception
adaptorChannel - the adaptor channelquery - the query to executedelegate - the processor delegate
Exception - if something goes wrong
public static javax.sql.rowset.CachedRowSet fetchRowSet(EOAdaptorChannel adaptorChannel,
String query)
throws Exception
adaptorChannel - the adaptor channelquery - the query to execute
Exception - if something goes wrong
|
Last updated: Thu, Jan 8, 2009 12:32 PM EST | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||