Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » DTP » Access Profile Manager @Runtime(ProfileManager.getInstance().getProfileByName @Runtime)
Access Profile Manager @Runtime [message #895216] Thu, 12 July 2012 07:44
Sudesh Bulathsinhala is currently offline Sudesh BulathsinhalaFriend
Messages: 193
Registered: October 2010
Senior Member

We have a plugin that consumes the available connection called postgres.sql from Data Source Explorer.
The connection is established and the database-schemas are available in the explorer during @design-time in IDE.

I followed the instructions given in

IConnectionProfile postgresProfile = ProfileManager.getInstance().getProfileByName("postgres.sql");
  IStatus status = profile.connect();
  if (status.getCode() == IStatus.OK)) {
     // success
  } else {
     // failure :(
     if (status.getException() != null) {

public java.sql.Connection getJavaConnectionForProfile (IConnectionProfile profile) {
     IManagedConnection managedConnection = ((IConnectionProfile)profile).
        getManagedConnection ("java.sql.Connection");
     if (managedConnection != null) {
        return (java.sql.Connection) managedConnection.getConnection().getRawConnection();
     return null;

java.sql.Connection conn = getJavaConnectionForProfile(postgresProfile);
  if (conn != null) {
     try {
        java.sql.Statement stmt = conn.createStatement();
        java.sql.ResultSet results = stmt.executeQuery("<INSERT QUERY/DDL HERE>");
     } catch (java.sql.SQLException sqle) {

However, once we invoke RCP application with this plugin, it always throw NPE, while executing the above code.

I debug and found the following returns an empty array during @runtime.
IConnectionProfile[] profiles = ProfileManager.getInstance().getProfiles();

Am I missing something here ?

Thanks & Regards,
Sudesh Bulathsinhala
Previous Topic:Connecting to MS Database 2008
Next Topic:input ddl without ui
Goto Forum:

Current Time: Tue Jan 26 01:01:50 GMT 2021

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

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

Back to the top