get connection object from driver manager

@param url
@param user
@param password
@return
348725
private Connection getConnectionViaDriverMangaer(String driver, String url, String user, String password) {

        Connection conn = null;
        try {
            Class.forName(driver);
            conn = DriverManager.getConnection(url, user, password);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return conn;
    }
1273379
public Connection getConnection() throws IOException {
		Connection conn = null;
		try {
			if (this.datasource != null) {
				try {
					Class.forName(datasource.get("driver"));
				} catch (ClassNotFoundException e) {
					throw new IOException("Load jdbc driver fail: " + datasource.get("driver"));
				}
				String url = datasource.get("url");
				String user = datasource.get("user");
				String password = datasource.get("password");
				if (StringUtils.isNoneBlank(user)) {
					conn = DriverManager.getConnection(url, user, password);
				} else {
					conn = DriverManager.getConnection(url);
				}
				conn.setAutoCommit(datasource.getBoolean("auto_commit", true));
			}
		} catch (Exception e) {
			throw new IOException(e);
		}
		return conn;
	}
691283
public URLConnection openConnection(URL url) throws IOException {
        Proxy proxy = getProxyFor(url);
        URLConnection conn = null;

        if (proxy != null) {
            conn = url.openConnection(proxy.getProxy());
            proxy.authenticate(conn);
        } else {
            conn = url.openConnection();
        }

        return conn;
    }
128848
@Override
    public Map<String, String> getUserInfo(PortletRequest request, PortletWindow portletWindow)
            throws PortletContainerException {

        Map<String, String> userInfo = new HashMap<String, String>();

        // check to see if a password is expected by this portlet
        if (isPasswordRequested(request, portletWindow)) {

            log.debug(
                    "Portlet named {} wants a password",
                    portletWindow.getPortletDefinition().getPortletName());

            final HttpServletRequest httpServletRequest =
                    this.portalRequestUtils.getPortletHttpRequest(request);
            final IUserInstance userInstance =
                    userInstanceManager.getUserInstance(httpServletRequest);
            final IPerson person = userInstance.getPerson();
            final ISecurityContext context = person.getSecurityContext();

            // if it is, attempt to request a password
            String password = getPassword(context);
            log.debug(password != null ? "Have a non-null password" : "password was null");
            if (this.decryptPassword && password != null) {
                log.debug("Attempting to decrypt password");
                password = stringEncryptionService.decrypt(password);
                log.debug(
                        "Password decryption complete, password is length {}",
                        password != null ? password.length() : "is null");
            }
            if (password != null) {
                userInfo.put(this.passwordKey, password);
                log.debug(
                        "Found password with length {} for portlet name {}",
                        password.length() != 0 ? "non-zero" : 0,
                        portletWindow.getPortletDefinition().getPortletName());
            }
        }
        return userInfo;
    }
284380
private String getUserPassword(Object[] args) throws AuthException {
		if (args == null)
			throw new AuthException("auth error: args is null");
		if ((userPasswordPair == null) || userPasswordPair.equals("")) {
			try {
				StringBuilder sb = new StringBuilder();
				if ((args[0] != null) && (args[1] != null)) {
					sb.append(args[0]);
					sb.append(":");
					sb.append(args[1]);
					userPasswordPair = sb.toString();
				}
			} catch (Exception e) {
				throw new AuthException("auth error: args is null");
			}
		}
		Debug.logVerbose("[JdonFramework] url param is" + userPasswordPair, module);
		return userPasswordPair;
	}
1084492
private static String getJmxResult(MBeanServerConnection connetion, String url) throws Exception {
        ObjectName name = new ObjectName(DruidStatService.MBEAN_NAME);

        return (String) conn.invoke(name, "service", new String[]{url},
                new String[]{String.class.getName()});
    }
1056292
private void initializeConnection(String user, String password, String restApiBaseUrl) {
		csrfToken = null;
		cookies = new HashMap<String, Cookie>();
		
		connection = ClientHelper.createClient().register(HttpAuthenticationFeature.basic(user, password)).target(restApiBaseUrl);
	}
257171
public Connection getConnectionByUrl(String dbPoolUrl) throws SQLException {

        return CmsDriverManager.m_pools.get(dbPoolUrl).getConnection();
    }
611566
private HttpURLConnection getURLConnection(String str)
            throws MalformedURLException {
        try {

            if (isHttps) {
                /* when communicating with the server which has unsigned or invalid
                * certificate (https), SSLException or IOException is thrown.
                * the following line is a hack to avoid that
                */
                Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
                System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
                if (isProxy) {
                    System.setProperty("https.proxyHost", proxyHost);
                    System.setProperty("https.proxyPort", proxyPort + "");
                }
            }
            else
            {
                if (isProxy)
                {
                    System.setProperty("http.proxyHost", proxyHost);
                    System.setProperty("http.proxyPort", proxyPort  + "");
                }
            }

            URL url = new URL(str);
            HttpURLConnection uc = (HttpURLConnection)url.openConnection();

            // if this header has not been set by a request set the user agent.
            if (headers == null ||
                    (headers != null &&  headers.get("user-agent") == null)) {
                // set user agent to mimic a common browser
                String ua="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)";
                uc.setRequestProperty("user-agent", ua);
            }

            uc.setInstanceFollowRedirects(false);

            return uc;
        }
        catch (MalformedURLException me)
        {
            throw new MalformedURLException(str + " is not a valid URL");
        }
        catch (Exception e)
        {
            throw new RuntimeException("Unknown error creating UrlConnection: " + e);
        }
    }
410158
public void jdbc(String driver, String url, String user, String password) {
        connectionWrapper.setConnectionSpec(new ConnectionJdbcSpec(driver, url, user, password));
    }
883550
def get_user_password (self, url):
        
        for auth in self["authentication"]:
            if auth['pattern'].match(url):
                return (auth['user'], auth['password'])
        return (None, None)
1021058
private ConnectionResults getConnection(final String userName, final String password,
                                            final Subject subject, final WSConnectionRequestInfoImpl cri, boolean useKerb,
                                            final Object credential)
                    throws ResourceException {
        final boolean trace = TraceComponent.isAnyTracingEnabled();
        if (trace && tc.isEntryEnabled())
            Tr.entry(this, tc, "getConnection",
                     userName, subject == null ? null : "subject", AdapterUtil.toString(cri),
                     useKerb, credential);

        ConnectionResults results;
        Connection conn;

        // Some JDBC drivers support propagation of GSS credential for kerberos via Subject.doAs
        if (useKerb && helper.supportsSubjectDoAsForKerberos())
            try {
                // Run this method as the subject.

                final PrivilegedExceptionAction<ConnectionResults> getConnection =
                                new PrivilegedExceptionAction<ConnectionResults>()
                                {
                                    public ConnectionResults run() throws ResourceException
                                    {
                                        return getConnection(userName, password, subject, cri, false, credential);
                                    }
                                };

                results = (ConnectionResults) AccessController.doPrivileged(
                                new PrivilegedExceptionAction<ConnectionResults>()
                                {
                                    public ConnectionResults run() throws Exception
                                    {
                                        // Work around a bug in JGSS where they add the kerberos ticket to the
                                        // private credentials, which prevents the subject from matching
                                        // connection requests and causes pooled connection to never be reused.
                                        // The work around is to copy the subject, so that the original isn't
                                        // modified.
                                        Subject copy = new Subject(subject.isReadOnly(),
                                                        subject.getPrincipals(),
                                                        subject.getPublicCredentials(),
                                                        subject.getPrivateCredentials());
                                        if (trace && tc.isDebugEnabled())
                                            Tr.debug(this, tc, "running as subject", copy);
                                        return Subject.doAs(copy, getConnection);
                                    }
                                });
            } catch (PrivilegedActionException privX) {
                Throwable x = privX.getCause();
                if (x instanceof PrivilegedActionException)
                    x = x.getCause();
                FFDCFilter.processException(x, getClass().getName(), "1734", this);
                if (trace && tc.isEntryEnabled())
                    Tr.exit(this, tc, "getConnection", x);

                if (x instanceof ResourceException)
                    throw (ResourceException) x;
                else
                    // shouldn't ever happen
                    throw new DataStoreAdapterException("GENERAL_EXCEPTION", null, getClass(), x.getMessage());
            }
        else if (DataSource.class.equals(type))
        {
            if (trace && tc.isDebugEnabled())
                Tr.debug(this, tc, "Getting a connection using Datasource. Is UCP? " + isUCP);
            conn = getConnectionUsingDS(userName, password, cri);
            results = new ConnectionResults(null, conn);
        } else if (Driver.class.equals(type)) {
            if (trace && tc.isDebugEnabled())
                Tr.debug(this, tc, "Getting a connection using Driver");
            conn = getConnectionUsingDriver(userName, password);
            results = new ConnectionResults(null, conn);
        } else {
            try {
                results = helper.getPooledConnection((CommonDataSource) dataSourceOrDriver, userName, password, XADataSource.class.equals(type), cri, useKerb, credential);
            } catch (DataStoreAdapterException dae) {
                throw (ResourceException) AdapterUtil.mapException(dae, null, this, false); // error can't be fired as we don't have an mc
            }
            results.connection = getConnection(results.pooledConnection, cri, userName);
        }

        if (trace && tc.isEntryEnabled())
            Tr.exit(this, tc, "getConnection", results);
        return results;
    }
1042343
def get_user(user, driver):  # noqa: E501
    

    response = ApitaxResponse()

    driver: Driver = LoadedDrivers.getDriver(driver)
    user: User = driver.getApitaxUser(User(username=user))
    response.body.add({'user': {'username': user.username, 'role': user.role}})

    return Response(status=200, body=response.getResponseBody())
753440
private Connection getConnection(final ICommandLine cl) throws SQLException, InstantiationException, IllegalAccessException,
            ClassNotFoundException {
        String database = DEFAULT_TABLE;
        if (cl.hasOption("database")) {
            database = cl.getOptionValue("database");
        }
        String hostname = DEFAULT_HOSTNAME;
        if (cl.hasOption("hostname") && !"".equals(cl.getOptionValue("hostname"))) {
            hostname = cl.getOptionValue("hostname");
        }
        String port = DEFAULT_PORT;
        if (cl.hasOption("port") && !"".equals(cl.getOptionValue("port"))) {
            port = cl.getOptionValue("port");
        }
        String password = "";
        if (cl.hasOption("password")) {
            password = cl.getOptionValue("password");
        }
        String username = "";
        if (cl.hasOption("logname")) {
            username = cl.getOptionValue("logname");
        }
        String timeout = DEFAULT_TIMEOUT;
        if (cl.getOptionValue("timeout") != null) {
            timeout = cl.getOptionValue("timeout");
        }
        Properties props = new Properties();
        props.setProperty("user", username);
        props.setProperty("password", password);
        props.setProperty("timeout", timeout);
        String url = "jdbc:postgresql://" + hostname + ":" + port + "/" + database;
        DriverManager.registerDriver((Driver) Class.forName("org.postgresql.Driver").newInstance());
        return DriverManager.getConnection(url, props);
    }
302602
public JMXConnector getJMXConnector(String controllerHost, int controllerPort, String user, String password) throws NoSuchAlgorithmException, KeyManagementException, MalformedURLException, IOException {
        HashMap<String, Object> environment = createJMXEnvironment(user, password, setUpSSLContext());
        JMXConnector connector = getMBeanServerConnection(controllerHost, controllerPort, environment);
        connector.connect();
        return connector;
    }
412604
public MBeanServerConnection getConnection(String jmxUrl, Hashtable attributes)
	{
		return getConnection(jmxUrl, attributes, false);
	}
1173544
public Connection getConnection(String poolUrl) throws SQLException {

        CmsDbPoolV11 pool = CmsDriverManager.m_pools.get(poolUrl);
        return pool.getConnection();

    }