Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 130209

Summary: [API] Need a way to access connection info for a table via public interfaces
Product: [Tools] Data Tools Reporter: Josh Knauer <joshua.knauer>
Component: ConnectivityAssignee: Brian Fitzpatrick <bfitzpat>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P1 CC: francis.lui, joshua.knauer, sean.johnson
Version: 0.7   
Target Milestone: 1.0RC0   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Josh Knauer CLA 2006-03-02 15:01:32 EST
There doesn't appear to be a way to access the ConnectionInfo for Table via public interfaces.

Suggestion:

Make ConnectionInfo and DatabaseConnectionRegistry public and then the following will work

Schema schema = table.getSchema();
Database database = schema.getDatabase();
ConnectionInfo connectionInfo = DatabaseConnectionRegistry.getConnectionForDatabase(database);
Comment 1 Rob Cernich CLA 2006-03-03 13:50:40 EST
Address this issue for 1.0.
Comment 2 Josh Knauer CLA 2006-03-09 12:25:38 EST
More specifically we need a way get the following things:

1) Database name
2) JDBC driver class name
3) JDBC URL
4) Username
5) Password
6) java.sql.Connection instance
Comment 3 Rob Cernich CLA 2006-04-17 15:12:25 EDT
setting priority to p2.  need to consult pmc regarding public api changes.  currently, there is no plan to refactor any of the SQM plug-ins until after callisto, so these issues may need to be addressed through documentation.
Comment 4 Rob Cernich CLA 2006-08-14 13:39:53 EDT
Estimate 1 day
Comment 5 Brian Fitzpatrick CLA 2006-09-26 11:34:43 EDT
Creating a utility class in sqm.core - org.eclipse.datatools.connectivity.sqm.core.util.ConnectionInfoUtils

This class provides the following helper methods, each passed a Database object. This should serve the needs of this requirement until such time as the ConnectionInfo and DatabaseConnectionRegistry APIs are refactored and made public (if this is done). If we need to add additional properties to expose via this utility class, we can do so, but I limited it to the list of properties provided in the bug description.

	public static String getDatabaseName ( Database database ) {
	public static String getJDBCDriverClassName ( Database database ) {
	public static String getJDBCURL ( Database database ) {
	public static String getUserName ( Database database ) {
	public static String getPassword ( Database database ) {
	public static Connection getSharedSQLConnectionInstance ( Database database ) {

If we need to, we can change the design slightly to make it less resource intensive (each call currently makes a call to get the ConnectionInfo object from the DatabaseConnectionRegistry and then serves up the info requested) by caching the ConnectionInfo object internally to the utility class. However, I chose not to do that for fear that stale information would be cached if users didn't reset it properly. If speed becomes an issue, we can revisit this.
Comment 6 Brian Fitzpatrick CLA 2006-10-25 16:04:19 EDT
At the request of the component lead, I have removed the ConnectionInfoUtils class and made public interfaces available for ConnectionFilter, ConnectionInfo, and the DatabaseConnectionRegistry utility. This refactoring should provide the information that was required by the bug initially.

Sorry for any confusion this causes.
Comment 7 Brian Fitzpatrick CLA 2006-10-25 16:04:44 EDT
Changing back to Fixed with the new changes
Comment 8 Rob Cernich CLA 2006-10-30 13:50:53 EST
Hey Brian, there are a couple of places that need to be updated.

Primarily, the id for the ConnectionInfo connection factory should be updated to new public name (org.eclipse.datatools.connectivity.sqm.core.connection.ConnectionInfo).

We need to update references in the plugin.xml files (mostly filter settings).

We also need to coordinate with the SQL dev team as there are a number of references in their project.  Post a note to the dev list or ping Hui or Hung.

Let me know if you need anything.
Rob
Comment 9 Brian Fitzpatrick CLA 2006-11-07 18:47:34 EST
Per comments from Rob, I have made and delivered some further changes to address BZ 130209, which has to do with refactoring the ConnectionInfo class. These new changes involve changing the factory ID from

org.eclipse.datatools.connectivity.sqm.internal.core.connection.ConnectionInfo

to

org.eclipse.datatools.connectivity.sqm.core.connection.ConnectionInfo

Hung, based on what Rob said, there are some changes that will need to be made in SQLTools to handle this change.
Comment 10 Brian Fitzpatrick CLA 2006-11-30 11:42:18 EST
Updated DatabaseConnectionRegistry to use public ConnectionInfo interface and added getConnectionProfile() to the public ConnectionInfo interface. 
Comment 11 Brian Fitzpatrick CLA 2008-07-01 16:33:07 EDT
Closed