Skip to main content



      Home
Home » Eclipse Projects » DTP » Getting java.sql.Connection from org.eclipse.datatools.modelbase.sql.tables.Table?
Getting java.sql.Connection from org.eclipse.datatools.modelbase.sql.tables.Table? [message #8466] Wed, 01 March 2006 18:02 Go to next message
Eclipse UserFriend
Hi,

I'm writing an org.eclipse.ui.popupMenus extension that is targetting the
org.eclipse.datatools.modelbase.sql.tables.Table object in Data Source
Explorer. What I would like the action to do is that if the table is JDBC
table, then use it to extract the JDBC connection information for the
connection that is containing table. The only way that I can figure out how
to do this is cast Table to
org.eclipse.datatools.connectivity.sqm.internal.core.rte.jdb c.JDBCTable and
then call getConnection to get the java.sql.Connection object which I cast
to a ConnectionAdapter. The ConnectionAdapter has a getConnectionInfo ()
which actually has what I want. My code looks something like this:

if (table isnstanceof JDBCTable)
{
JDBCTable jdbcTable = (JDBCTable) table;
ConnectionAdapter connection = (ConnectionAdapter)
jdbcTable.getConnection ();
ConnectionInfo info = connection.getConnectionInfo ();

String url = info.getURL ();
//etc ...
}

The trouble here is that I'm using JDBCTable, ConnectionAdapter and
ConnectionInfo which are all internal DTP classes.

Is it possible to get the connection information for a table using public
DTP classes?

Thanks!

Josh
Re: Getting java.sql.Connection from org.eclipse.datatools.modelbase.sql.tables.Table? [message #8497 is a reply to message #8466] Thu, 02 March 2006 13:11 Go to previous messageGo to next message
Eclipse UserFriend
Hey Josh,

Glad to see you're trying to extend the DSE.

Try the following:
Schema schema = table.getSchema();
Database database = schema.getDatabase();
ConnectionInfo connectionInfo =
DatabaseConnectionRegistry.getConnectionForDatabase(database );

This method should allow you to access the ConnectionInfo object related
to any Table (not just the specialized JDBCTable).

Hope this helps.
Rob
Re: Getting java.sql.Connection from org.eclipse.datatools.modelbase.sql.tables.Table? [message #8528 is a reply to message #8497] Thu, 02 March 2006 13:39 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for the reply Rob ... this is close, but DatabaseConnectionRegistry
and ConnectionInfo are both in the
org.eclipse.datatools.connectivity.sqm.internal.core.connect ion package ...
i.e. they're internal to the DTP plug-in. I need a way to get connection
information without using internal interfaces in DTP.


"Rob Cernich" <rcernich@sybase.com> wrote in message
news:db2c94269eb8ebb00e5deff338f58369$1@www.eclipse.org...
> Hey Josh,
>
> Glad to see you're trying to extend the DSE.
>
> Try the following:
> Schema schema = table.getSchema();
> Database database = schema.getDatabase();
> ConnectionInfo connectionInfo =
> DatabaseConnectionRegistry.getConnectionForDatabase(database );
>
> This method should allow you to access the ConnectionInfo object related
> to any Table (not just the specialized JDBCTable).
>
> Hope this helps.
> Rob
>
Re: Getting java.sql.Connection from org.eclipse.datatools.modelbase.sql.tables.Table? [message #8557 is a reply to message #8528] Thu, 02 March 2006 14:37 Go to previous message
Eclipse UserFriend
Hey Josh,

Currently, DTP only exposes a provisional API, which, at this point, is
under review. Please feel free to recommend that these classes be
included as part of the public API. (I think ConnectionInfo is part of
the public API, but has not been refactored out of its "internal" package.)

Also, if you feel other classes/interfaces would be useful to extension
developers, please recommend those as well.

Please create bugzilla entries for any API requests/changes.

Sincerely,
Rob
Re: Getting java.sql.Connection from org.eclipse.datatools.modelbase.sql.tables.Table? [message #570934 is a reply to message #8466] Thu, 02 March 2006 13:11 Go to previous message
Eclipse UserFriend
Hey Josh,

Glad to see you're trying to extend the DSE.

Try the following:
Schema schema = table.getSchema();
Database database = schema.getDatabase();
ConnectionInfo connectionInfo =
DatabaseConnectionRegistry.getConnectionForDatabase(database );

This method should allow you to access the ConnectionInfo object related
to any Table (not just the specialized JDBCTable).

Hope this helps.
Rob
Re: Getting java.sql.Connection from org.eclipse.datatools.modelbase.sql.tables.Table? [message #570953 is a reply to message #8497] Thu, 02 March 2006 13:39 Go to previous message
Eclipse UserFriend
Thanks for the reply Rob ... this is close, but DatabaseConnectionRegistry
and ConnectionInfo are both in the
org.eclipse.datatools.connectivity.sqm.internal.core.connect ion package ...
i.e. they're internal to the DTP plug-in. I need a way to get connection
information without using internal interfaces in DTP.


"Rob Cernich" <rcernich@sybase.com> wrote in message
news:db2c94269eb8ebb00e5deff338f58369$1@www.eclipse.org...
> Hey Josh,
>
> Glad to see you're trying to extend the DSE.
>
> Try the following:
> Schema schema = table.getSchema();
> Database database = schema.getDatabase();
> ConnectionInfo connectionInfo =
> DatabaseConnectionRegistry.getConnectionForDatabase(database );
>
> This method should allow you to access the ConnectionInfo object related
> to any Table (not just the specialized JDBCTable).
>
> Hope this helps.
> Rob
>
Re: Getting java.sql.Connection from org.eclipse.datatools.modelbase.sql.tables.Table? [message #570971 is a reply to message #8528] Thu, 02 March 2006 14:37 Go to previous message
Eclipse UserFriend
Hey Josh,

Currently, DTP only exposes a provisional API, which, at this point, is
under review. Please feel free to recommend that these classes be
included as part of the public API. (I think ConnectionInfo is part of
the public API, but has not been refactored out of its "internal" package.)

Also, if you feel other classes/interfaces would be useful to extension
developers, please recommend those as well.

Please create bugzilla entries for any API requests/changes.

Sincerely,
Rob
Previous Topic:Getting java.sql.Connection from org.eclipse.datatools.modelbase.sql.tables.Table?
Next Topic:RC0 & MySQL problems
Goto Forum:
  


Current Time: Wed Apr 16 10:26:58 EDT 2025

Powered by FUDForum. Page generated in 0.03374 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top