/** * * @param dbType * @return */ public static DBHelper getDBHelper(String dbType) { return getDBHelper(null, dbType); }
/** * * @param databaseIdentifier * @return */ public static DBHelper getDBHelper(DatabaseIdentifier databaseIdentifier) { return getDBHelper(databaseIdentifier, null); }
public String getSQLStatements() { return _sqlEditor == null ? null : SQLToolsFacade.getDBHelper(getDatabaseIdentifier()).preprocessSQLScript(_sqlEditor.getSelectedText()); }
public String getSQLStatements() { return _sqlEditor == null ? null : SQLToolsFacade.getDBHelper(getDatabaseIdentifier()).preprocessSQLScript(_sqlEditor.getText()); }
/** * Gets the shared connection from the connection profile * TODO Now this method delegates to IConnectionProfile, which doesn't manage a connection for each * database. * @param databaseIdentifier database identifier used to locate the connection profile * @return the shared connection managed by the connection profile * @throws SQLException * @throws NoSuchProfileException */ public static Connection getReusableConnection(DatabaseIdentifier databaseIdentifier) throws SQLException, NoSuchProfileException { IConnectionProfile profile = getProfile(databaseIdentifier.getProfileName()); if (!profile.isConnected()) { throw new SQLException(NLS.bind(Messages.ProfileUtil_error_not_connected, (new Object[]{databaseIdentifier.getProfileName()}))); } IManagedConnection managedConn = profile.getManagedConnection("java.sql.Connection"); if (managedConn == null || !managedConn.isConnected()) { throw new SQLException(NLS.bind(Messages.ProfileUtil_error_getReusableConnection, (new Object[]{databaseIdentifier.toString()}))); } IConnection iconn = managedConn.getConnection(); DBHelper helper = SQLToolsFacade.getDBHelper(databaseIdentifier); Connection conn = (Connection)iconn.getRawConnection(); helper.switchDatabase(databaseIdentifier, conn); return conn; }
/** * Construct a ServerIdentifier from a connection profile. * @param profileName * @return */ public static ServerIdentifier getServerIdentifier(DatabaseIdentifier databaseIdentifier) { ProfileManager pManager = ProfileManager.getInstance(); IConnectionProfile connProfile1 = pManager.getProfileByName(databaseIdentifier.getProfileName()); if(connProfile1 == null) { return null; } Properties profile1Props = connProfile1.getBaseProperties(); //TODO CONN won't support host and port anymore? // String host = profile1Props.getProperty(HOST); // String port = profile1Props.getProperty(PORT); String host = null; String port = null; String url = profile1Props.getProperty(URL); DBHelper helper = SQLToolsFacade.getDBHelper(databaseIdentifier); return helper.getServerIdentifier(host, port, url, ProfileUtil.getDatabaseVendorDefinitionId(databaseIdentifier.getProfileName())); }
DBHelper helper = SQLToolsFacade.getDBHelper(databaseIdentifier); helper.switchDatabase(databaseIdentifier, conn);
DBHelper helper = SQLToolsFacade.getDBHelper(databaseIdentifier); Connection conn = (Connection)iconn.getRawConnection(); helper.switchDatabase(databaseIdentifier, conn);