public Database getDatabase() { if (_database == null && _profileName != null ) { _database = ProfileUtil.getDatabase(new DatabaseIdentifier( _profileName, _databaseName)); } return _database; }
/** * Constructs a runnable to execute a group of SQL statements. * * @param request the plan request * @param databaseIdentifier the database identifier * @param postRun the runnable which will be invoked at last */ public GroupPlanSupportRunnable(PlanRequest request, DatabaseIdentifier databaseIdentifier, Runnable postRun) { super(request, databaseIdentifier.getProfileName(), databaseIdentifier.getDBname()); this._postRun = postRun; }
public void setProfileName(String profileName) { _database.setProfileName(profileName); }
/** * 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; }
public String getProfileName() { return _database.getProfileName(); }
String db = _database.getDBname(); db = SQLDevToolsUtil.quoteWhenNecessary(db, new DatabaseIdentifier(_database.getProfileName(), db)); if (quoted_id)
_databaseIdentifier = new DatabaseIdentifier(profileName, dbName); .getProfileName()); IDataServerLaunchPreferenceSection accessor = (IDataServerLaunchPreferenceSection) _sections.get(conf .getDatabaseVendorDefinitionId().toString());
public String getDatabaseName() { return _database.getDBname(); }
DatabaseIdentifier databaseIdentifier = new DatabaseIdentifier(profile.getName(), dbName); if (databaseIdentifier.getDBname() != null && !databaseIdentifier.getDBname().trim().equals("")) { EditorCorePlugin.getControlConnectionManager() .getOrCreateControlConnection(databaseIdentifier);
public boolean equals(Object obj) { if (obj instanceof ProcIdentifierImpl) { ProcIdentifierImpl p = (ProcIdentifierImpl) obj; boolean e = getDatabaseIdentifier().equals(p.getDatabaseIdentifier()) && (getType() == p.getType()) && propertyMap.equals(p.propertyMap); return e; } return false; }
public IControlConnection getControlConnection(DatabaseIdentifier databaseIdentifier) { IControlConnection controlConnection = (IControlConnection) _controlConnectionMap.get(databaseIdentifier); if (controlConnection == null) { IControlConnection[] cc = getControlConnection(databaseIdentifier.getProfileName()); if (cc != null && cc.length > 0) { controlConnection = cc[0]; } } return controlConnection; }
_databaseIdentifier = new DatabaseIdentifier(profileName, dbName); if (_databaseIdentifier.getProfileName() != null && !_databaseIdentifier.getProfileName().trim().equals("") && ProfileUtil.profileExist(_databaseIdentifier.getProfileName())) //$NON-NLS-1$
throw new NoSuchProfileException(databaseIdentifier.toString()); throw new SQLException(NLS.bind(Messages.ControlConnectionManager_unknownServerType, (new Object[]{databaseIdentifier.getProfileName()})));
public String[] getSysDatabaseNames(DatabaseIdentifier identifier) { if (identifier != null) { return new String[] { identifier.getDBname() } ; } return null; }
/** * Returns whether the given object equals to this ProcIdentifier object. * If the profile names are different, the comparison will base on the * server url. * @param obj * @return */ public boolean equalsByServer(Object obj) { if (obj instanceof ProcIdentifierImpl) { ProcIdentifierImpl p = (ProcIdentifierImpl) obj; boolean e = getDatabaseIdentifier().equals(p.getDatabaseIdentifier()); if (! e) { ServerIdentifier si1 = ProfileUtil.getServerIdentifier(getDatabaseIdentifier()); ServerIdentifier si2 = ProfileUtil.getServerIdentifier(p.getDatabaseIdentifier()); e = si1.equals(si2); } e = e && (getType() == p.getType()) && propertyMap.equals(p.propertyMap); return e; } return false; }
/** * Closes the connection object. Subclasses may need to do further log or cleanup jobs. * @param connection * @param connId * @param databaseIdentifier * @throws SQLException */ public void closeConnection(Connection connection, int connId, DatabaseIdentifier databaseIdentifier) throws SQLException { ProfileUtil.closeConnection(databaseIdentifier.getProfileName(), databaseIdentifier.getDBname(), connection); }
public static DatabaseIdentifier readDatabaseIdentifier(ILaunchConfiguration configuration) throws CoreException { String profileName = configuration.getAttribute(ROUTINE_LAUNCH_PROFILENAME, ""); String dbName = configuration.getAttribute(ROUTINE_LAUNCH_DATABASENAME, ""); if ("".equals(profileName)) { throw new CoreException(new Status(IStatus.ERROR, RoutineEditorActivator.PLUGIN_ID, 0, Messages.LaunchHelper_invalid_launch_configuration, null)); } else { return new DatabaseIdentifier(profileName, dbName); } }
public IControlConnection[] getControlConnections(String profileName) { List controlConnections = new ArrayList(); //Get key set Set databaseIdentifierSet = _controlConnectionMap.keySet(); Iterator iterator = databaseIdentifierSet.iterator(); List databaseIdentifiers = new ArrayList(); while(iterator.hasNext()) { databaseIdentifiers.add(iterator.next()); } if (databaseIdentifiers.size() < 1) { return new IControlConnection[0]; } for (int i = 0; i < databaseIdentifiers.size(); i++) { DatabaseIdentifier databaseIdentifier = ((DatabaseIdentifier) databaseIdentifiers.get(i)); if (databaseIdentifier.getProfileName().equals(profileName)) { controlConnections.add(_controlConnectionMap.get(databaseIdentifier)); } } return (IControlConnection[]) controlConnections.toArray( new IControlConnection[controlConnections.size()]); }
DatabaseIdentifier databaseIdentifier = new DatabaseIdentifier(profileName, dbName); if (profileName == null || profileName.trim().length() == 0 || !ProfileUtil.isDatabaseProfile(databaseIdentifier.getProfileName()) || dbName == null || dbName.trim().length() == 0) if (profileName == null || profileName.trim().length() == 0 || !ProfileUtil.isDatabaseProfile(databaseIdentifier.getProfileName())) SWTUtils.recursiveEnable(_grRunString, true); DatabaseDefinition dbDef = ProfileUtil.getDatabaseDefinition(databaseIdentifier.getProfileName()); if (dbDef != null)
IConnectionProfile profile = getProfile(databaseIdentifier.getProfileName()); if (!profile.isConnected()) connectProfile(databaseIdentifier.getProfileName()); throw new SQLException(NLS.bind(Messages.ProfileUtil_error_getReusableConnection, (new Object[]{databaseIdentifier.toString()})));