Making connection profile or Database programatic [message #9554] |
Sat, 18 March 2006 01:58  |
Eclipse User |
|
|
|
Hello,
Is it possible and if yes is there some documentation or start point.
I have tried make database instance like this
Database database = new JDBCDatabase(connection);
but it fail in this code (JDBCDatabase#loadSchemas line 91)
ConnectionInfo connectionInfo =
DatabaseConnectionRegistry.getInstance().getConnectionForDat abase(this);
ConnectionFilter filter =
connectionInfo.getFilter(this.getName()+"::"+ConnectionFilter.SCHEMA_FILTER); //$NON-NLS-1$
if (filter == null) { //if schema filter is null, then get default filter
filter = connectionInfo.getFilter(ConnectionFilter.SCHEMA_FILTER);
}
maybe this is better :
ConnectionInfo connectionInfo =
DatabaseConnectionRegistry.getInstance().getConnectionForDat abase(this);
if (connectionInfo != null) {
ConnectionFilter filter =
connectionInfo.getFilter(this.getName()+"::"+ConnectionFilter.SCHEMA_FILTER); //$NON-NLS-1$
if (filter == null) { //if schema filter is null, then get default filter
filter = connectionInfo.getFilter(ConnectionFilter.SCHEMA_FILTER);
}
}
Best
Peco
|
|
|
|
|
|
Re: Making connection profile or Database programatic [message #571707 is a reply to message #9554] |
Fri, 24 March 2006 14:04  |
Eclipse User |
|
|
|
Hello Peco,
Sorry for the lack of documentation. It is one of the things we will be
working on as we move towards the Callisto release. Hopefully, the
following example will help.
The SQL model can be accessed through a connection factory associated with
connection profile you are using. You should use the connection factory
ID'd by the ConnectionInfo class.
For example,
IConnection connection =
someConnectionProfile.createConnection(ConnectionInfo.class. getName());
ConnectionInfo connectionInfo =
(ConnectionInfo)connection.getRawConnection();
Database db = connectionInfo.getDatabase();
Connection jdbcConnection = connectionInfo.getSharedConnection();
Alternately, if you wish to use the shared model associated with the
connection profile... (this assumes the connection profile is in a
"connected" state; someConnectionProfile.connect())
IManagedConnection managedConnection =
someConnectionProfile.getManagedConnection(ConnectionInfo.cl ass.getName());
IConnection connection = managedConnection.getConnection();
ConnectionInfo ....<same as above from here on>
Hope that helps you along. Please let me know if you need more
information.
Sincerely,
Rob
|
|
|
Re: Making connection profile or Database programatic [message #571770 is a reply to message #9690] |
Fri, 24 March 2006 18:52  |
Eclipse User |
|
|
|
Rob,
I have java.sql.Connection (connected to database) and i want
make Database instance (for using sql parser in non-datatools
editor).I haven't ConnectionInfo (and i needn't it)
It work fine except part of code in my example:
datatools check if filter is null, but doesn't check if
ConnectionInfo is null.
I don't want make connection profile from existing datatools
connection profile - i have nothing except raw datatools plugin
and want use parser part only
Thanks
PS
Can datatools handle databases wich supports catalog and schema
like MS SQL and Sybase (i see getSchemas method, but don't see
getCatalogs or similar)
Rob Cernich wrote:
> Hello Peco,
>
> Sorry for the lack of documentation. It is one of the things we will be
> working on as we move towards the Callisto release. Hopefully, the
> following example will help.
>
> The SQL model can be accessed through a connection factory associated with
> connection profile you are using. You should use the connection factory
> ID'd by the ConnectionInfo class.
>
> For example,
>
> IConnection connection =
> someConnectionProfile.createConnection(ConnectionInfo.class. getName());
> ConnectionInfo connectionInfo =
> (ConnectionInfo)connection.getRawConnection();
> Database db = connectionInfo.getDatabase();
> Connection jdbcConnection = connectionInfo.getSharedConnection();
>
> Alternately, if you wish to use the shared model associated with the
> connection profile... (this assumes the connection profile is in a
> "connected" state; someConnectionProfile.connect())
>
> IManagedConnection managedConnection =
>
someConnectionProfile.getManagedConnection(ConnectionInfo.cl ass.getName());
> IConnection connection = managedConnection.getConnection();
> ConnectionInfo ....<same as above from here on>
>
> Hope that helps you along. Please let me know if you need more
> information.
>
> Sincerely,
> Rob
|
|
|
|
Powered by
FUDForum. Page generated in 0.05880 seconds