Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » DTP » SQL Editor -Update Connection Profile programmatic way(Edit Connection Profile programmatically)
SQL Editor -Update Connection Profile programmatic way [message #661044] Tue, 22 March 2011 17:16 Go to next message
Swati Sapar is currently offline Swati Sapar
Messages: 20
Registered: September 2010
Junior Member
Hi,

I want to edit the connection profile that an SQL scrapbook is associated with from the Java code.
I am updating this based on the connection profile selected in SQL Explorer.

My code looks like this :

ISQLEditorConnectionInfo sqlConnectioninfo=((SQLEditor)activeeditor).getConnectionInf o();
sqlConnectioninfo.setConnectionProfileName(conprof.getName() );
sqlConnectioninfo.setProfileStatus(conprof.getConnectionStat e());

Properties properties = conprof.getBaseProperties();
String schemaName= properties.get("org.eclipse.datatools.connectivity.db.databaseName ").toString();
sqlConnectioninfo.setDefaultSchemaName(schemaName);

sqlConnectioninfo.setDatabaseVendorDefinitionId(new
DatabaseVendorDefinitionId(properties.getProperty("org.eclipse.datatools.connectivity.db.vendor ").toString(),properties.getProperty("org.eclipse.datatools.connectivity.db.version ").toString()));

((SQLEditor)activeeditor).setConnectionInfo(sqlConnectioninf o);
((SQLEditor) activeeditor).refreshConnectionStatus();


This does update the Type , Name and Status in connection Profile.
How can I select a default value for Database: field ??
Please find snapshot here:

https:// docs.google.com/leaf?id=0B6xpLLyeT_sYMmUxZDQzZWUtNjVmYS00YWE yLWFhMGYtZDdiODJlM2RmZDY3&sort=name&layout=list& num=50

Thank you,
Swati
icon14.gif  Re: SQL Editor -Update Connection Profile programmatic way [message #661668 is a reply to message #661044] Fri, 25 March 2011 18:12 Go to previous message
Swati Sapar is currently offline Swati Sapar
Messages: 20
Registered: September 2010
Junior Member
Found a solution myself.

Create an annonymous SQLEditorConnectionInfo as below and override the getdatabasename method to set the desired db name.


ISQLEditorConnectionInfo sqlConnectioninfo=new SQLEditorConnectionInfo(SQLToolsFacade.getNonSpecificDatabas eVendorDefinitionId()) {
public String getDatabaseName()
{
return dbName;
}
};


Smile
Previous Topic:Need Help about ODA Ecore
Next Topic:Embedding SQLBuilder Component
Goto Forum:
  


Current Time: Thu Jul 31 11:36:15 EDT 2014

Powered by FUDForum. Page generated in 0.02067 seconds