Re: exec sp_password using rawRowsForSQL
Re: exec sp_password using rawRowsForSQL
- Subject: Re: exec sp_password using rawRowsForSQL
- From: Jerry Haynes <email@hidden>
- Date: Thu, 20 Apr 2006 11:38:03 -0400
Patrick, your example got me thinking about some code I had used in
the past. It works but I still do not get a result from this
particular stored procedure. Other Sybase built-in stored procedures
that I tried (sp_helpdb is one example) do return a result set. It's
a in-house only project so I say it's good enough.
Create a Stored Procedure in EOModeler:
Name Direction Value Class External Type Column Width
masterPassword In NSString varchar A 30
newPassword In NSString varchar B 31
userName In NSString varchar C 30
private boolean setSybasePassword(EOEditingContext editingContext,
String eoModel, String masterPassword, String newPassword, String
userName) {
NSMutableArray result = new NSMutableArray();
boolean channelWasOpen = true;
NSArray attrArray;
NSDictionary row;
int i,count;
EOAdaptorChannel adaptorChannel = null;
EOModelGroup defaultGroup = EOModelGroup.defaultGroup();
EODatabaseContext dbContext =
EOUtilities.databaseContextForModelNamed(editingContext, eoModel);
try {
dbContext.lock();
EODatabaseChannel dbChannel = dbContext.availableChannel();
adaptorChannel = dbChannel.adaptorChannel();
if (!adaptorChannel.isOpen()) {
channelWasOpen = false;
adaptorChannel.openChannel();
}
Connection conn = ((JDBCContext)dbContext.adaptorContext
()).connection();
// Set the JDBC Connection's autoCommit to 'true', i.e. unchained
transactions.
conn.setAutoCommit(true);
EOStoredProcedure spPassword = defaultGroup.storedProcedureNamed
("sp_password");
//Arguments for the stored procedure.
NSMutableDictionary args = new NSMutableDictionary();
args.setObjectForKey ( masterPassword, "masterPassword" );
args.setObjectForKey ( newPassword, "newPassword" );
args.setObjectForKey ( userName, "userName" );
//Call the stored procedure.
adaptorChannel.executeStoredProcedure(spPassword, args);
if (adaptorChannel.isFetchInProgress()) {
attrArray = adaptorChannel.describeResults();
count = attrArray.count();
for (i=0; i<count; i++) {
EOAttribute attr=(EOAttribute)attrArray.objectAtIndex(i);
attr.setName((String)attr.columnName());
}
adaptorChannel.setAttributesToFetch(attrArray);
}
while(adaptorChannel.isFetchInProgress()) {
while ((row = adaptorChannel.fetchRow()) != null) {
NSLog.out.appendln("*********** " + row + " ************");
}
}
}
catch (Exception e) {
NSLog.out.appendln("NOTICE: An exception occured while calling
stored procedure. Message is " + e.getMessage() );
adaptorChannel.cancelFetch();
return false;
}
finally {
dbContext.unlock();
if (adaptorChannel.isOpen() && !channelWasOpen)
adaptorChannel.closeChannel();
}
return true;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden