Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

DTP FAQ

Revision as of 12:44, 1 October 2009 by Unnamed Poltroon (Talk)

Back to DTP Main Page


DTP Frequently Asked Questions (FAQ)

Connectivity

Q: How do I programmatically access an existing connection profile?

A: This is pretty simple:

  IConnectionProfile profile = ProfileManager.getInstance().getProfileByName("myprofile");

Q: How do I connect to an existing connection profile programmatically?

A: Again, pretty simple:

  IConnectionProfile profile = ProfileManager.getInstance().getProfileByName("myprofile");
  IStatus status = profile.connect();
  if (status.equals(IStatus.OK)) {
     // success
  } else {
     // failure :(
     if (status.getException() != null) {
        status.getException().printStackTrace();
     }
  } 

Q: How do I get the raw JDBC Connection from my connected connection profile?

  public java.sql.Connection getJavaConnectionForProfile (IConnectionProfile profile) {
     IConnection connection = ProfileConnectionManager.getProfileConnectionManagerInstance().getConnection(profile,"java.sql.Connection");
     if (connection != null) {
        return (java.sql.Connection) connection.getRawConnection();
     }
     return null;
  }

Back to the top