Get {@link NamedParameterJdbcTemplate} instance for a given
{@link Connection}.

Note: the returned {@link JdbcTemplate} will not automatically close the
{@link Connection}.

@param conn
@return
@since 0.8.0
193423
protected NamedParameterJdbcTemplate namedParameterJdbcTemplate(Connection conn) {
        DataSource ds = new SingleConnectionDataSource(conn, true);
        return new NamedParameterJdbcTemplate(ds);
    }
562857
public static Connection newInstance(Connection conn) {
        return (Connection) java.lang.reflect.Proxy.newProxyInstance(Connection.class.getClassLoader(), new Class[]{Connection.class},
                new ConnectionProxy(conn));
        /*
        return (Connection) java.lang.reflect.Proxy.newProxyInstance(conn.getClass().getClassLoader(), conn.getClass().getInterfaces(),
                new ConnectionProxy(conn));
                */
    }
91053
public final Connection getConnection(final String dataSourceName) throws SQLException {
        return getConnections(ConnectionMode.MEMORY_STRICTLY, dataSourceName, 1).get(0);
    }
863016
public <CT> CT callBatchTasks(ConnectionSource connectionSource, Callable<CT> callable) throws SQLException {
		if (connectionSource.isSingleConnection(tableInfo.getTableName())) {
			synchronized (this) {
				return doCallBatchTasks(connectionSource, callable);
			}
		} else {
			return doCallBatchTasks(connectionSource, callable);
		}
	}
480877
public static SqlConfig getConfig(final Connection conn, final String loadPath) {
		return new DefaultSqlConfig(new DefaultConnectionSupplierImpl(conn), loadPath);
	}
274032
public SQLTemplates.Builder getBuilder(DatabaseMetaData md) throws SQLException {
        String name = md.getDatabaseProductName().toLowerCase();
        if (name.equals("cubrid")) {
            return CUBRIDTemplates.builder();
        } else if (name.equals("apache derby")) {
            return DerbyTemplates.builder();
        } else if (name.startsWith("firebird")) {
            return FirebirdTemplates.builder();
        } else if (name.equals("h2")) {
            return H2Templates.builder();
        } else if (name.equals("hsql")) {
            return HSQLDBTemplates.builder();
        } else if (name.equals("mysql")) {
            return MySQLTemplates.builder();
        } else if (name.equals("oracle")) {
            return OracleTemplates.builder();
        } else if (name.equals("postgresql")) {
            return PostgreSQLTemplates.builder();
        } else if (name.equals("sqlite")) {
            return SQLiteTemplates.builder();
        } else if (name.startsWith("teradata")) {
            return TeradataTemplates.builder();
        } else if (name.equals("microsoft sql server")) {
            switch (md.getDatabaseMajorVersion()) {
                case 13:
                case 12:
                case 11: return SQLServer2012Templates.builder();
                case 10: return SQLServer2008Templates.builder();
                case 9:  return SQLServer2005Templates.builder();
                default: return SQLServerTemplates.builder();
            }
        } else {
            return new SQLTemplates.Builder() {
                @Override
                protected SQLTemplates build(char escape, boolean quote) {
                    return new SQLTemplates(Keywords.DEFAULT, "\"", escape, quote, false);
                }
            };
        }
    }
474579
@SuppressWarnings("unchecked")
	public Object toJdbc(final Object object, final Connection connection) {
		if (object == null) {
			return null;
		}
		for (@SuppressWarnings("rawtypes")
		BindParameterMapper parameterMapper : mappers) {
			if (parameterMapper.canAccept(object)) {
				return parameterMapper.toJdbc(object, connection, this);
			}
		}

		if (object instanceof Boolean || object instanceof Byte || object instanceof Short || object instanceof Integer
				|| object instanceof Long || object instanceof Float || object instanceof Double
				|| object instanceof BigDecimal || object instanceof String

				|| object instanceof byte[]

				|| object instanceof java.sql.Date || object instanceof java.sql.Time
				|| object instanceof java.sql.Timestamp || object instanceof java.sql.Array
				|| object instanceof java.sql.Ref || object instanceof java.sql.Blob || object instanceof java.sql.Clob
				|| object instanceof java.sql.SQLXML

				|| object instanceof java.sql.Struct) {
			return object;
		}

		for (@SuppressWarnings("rawtypes")
		BindParameterMapper parameterMapper : DEFAULT_MAPPERS) {
			if (parameterMapper.canAccept(object)) {
				return parameterMapper.toJdbc(object, connection, this);
			}
		}
		return object;
	}
531242
public DataSource createDataSourceFromConnectionInfo(final ConnectionInfo connectionInfo) throws SQLException
    {
        final PGSimpleDataSource ds = new PGSimpleDataSource();
        ds.setPortNumber(connectionInfo.getPort());
        ds.setDatabaseName(connectionInfo.getDbName());
        ds.setUser(connectionInfo.getUser());
        return ds;
    }
1202079
public static int[] executeBatch(Connection conn, String sql, Object[]... paramsBatch) throws SQLException {
		return executeBatch(conn, sql, new ArrayIter<Object[]>(paramsBatch));
	}
1008690
function connStr(conn) {
  var conf = mergeDefaults(conn);
  var connString = conf.driver + '://' + conf.username + (conf.password ? ':' + conf.password : '') + '@' + conf.host
    + (conf.port ? ':' + conf.port : '') + '/' + conf.database;
  return connString;
}
935059
public static PreparedStatement prepareStatementForBatch(Connection conn, String sql, Iterable<Object[]> paramsBatch) throws SQLException {
		Assert.notBlank(sql, "Sql String must be not blank!");

		sql = sql.trim();
		SqlLog.INSTASNCE.log(sql, paramsBatch);
		PreparedStatement ps = conn.prepareStatement(sql);
		for (Object[] params : paramsBatch) {
			StatementUtil.fillParams(ps, params);
			ps.addBatch();
		}
		return ps;
	}
11902
public Collection<JndiObjectResourceParameter> getParameters(DbConn cnx)
    {
        ResultSet rs = cnx.runSelect("jndiprm_select_all_in_jndisrc", this.id);
        List<JndiObjectResourceParameter> res = new ArrayList<>();
        JndiObjectResourceParameter tmp = null;
        try
        {
            while (rs.next())
            {
                tmp = new JndiObjectResourceParameter();
                tmp.setId(rs.getInt(1));
                tmp.setKey(rs.getString(2));
                tmp.setLastModified(cnx.getCal(rs, 3));
                tmp.setValue(rs.getString(4));

                res.add(tmp);
            }
        }
        catch (Exception e)
        {
            throw new DatabaseException(e);
        }
        return res;
    }
1325499
public static function getDSN($db_hostname = null, $db_driver = null, $db_port = null, $db_schema = null): string
    {
        try {
            // Check whether $db_hostname is set
            if (!$db_hostname) {
                // if not, try to use self::$db_params['db_hostname']
                if (!isset(self::$db_params['db_hostname'])) {
                    throw new \Exception('Database host not set');
                } else {
                    $db_hostname = self::$db_params['db_hostname'];
                }
            }

            // Check whether $db_driver is set
            if (!$db_driver) {
                // if not, try to use self::$db_params['db_driver']
                if (!isset(self::$db_params['db_driver'])) {
                    throw new \Exception('Database driver not set');
                } else {
                    $db_driver = self::$db_params['db_driver'];
                }
            }

            // Check whether $db_schema is set
            if (!$db_schema) {
                // if not, try to use self::$db_params['db_schema']
                if (!isset(self::$db_params['db_schema'])) {
                    throw new \Exception('Database name not set');
                } else {
                    $db_schema = self::$db_params['db_schema'];
                }
            }

            // Check whether $db_port is set
            if (!$db_port) {
                // if not, try to use self::$db_params['db_port']
                if (!isset(self::$db_params['db_port'])) {
                    // throw new \Exception('Database port not set');
                    $db_port = "";
                } else {
                    $db_port = self::$db_params['db_port'];
                }
            }

            // Make DNS
            if ($db_driver === 'mysql') {
                $dsn =  $db_driver .
                        ":host=" .
                        $db_hostname;

                $db_port = empty($db_port) ? "" : (":" . $db_port) ;

                $dsn .= $db_port .
                        ";dbname=" .
                        $db_schema;
            } elseif ($db_driver === 'sqlite') {
                // In case database type is sqlite,
                // 'dbname' param stores path to the database file.
                $dsn =  $db_driver . ':'. $db_schema;
            } else {
                throw new \Exception("Database type '". self::$db_params['db_driver'] . "' does not support yet.");
            }

            return $dsn;
        } catch (\Exception $e) {
            die('Error: ' . $e->getMessage());
        }

        return false;
    }
708524
protected Stream<T> getAll(Connection conn) {
        return executeSelectAsStream(rowMapper, conn, true, calcSqlSelectAll());
    }
160086
private JdbcTemplateProxy getProxy(){
		if(_proxy == null){
			_proxy = new JdbcTemplateProxy();
			_proxy.setJdbcTemplate(jdbcTemplate);
		}
		return _proxy;
	}
1225753
private String determineDatabaseProductName(Connection conn) {
        try {
            final String databaseProductName = conn.getMetaData().getDatabaseProductName().toLowerCase();
            LOGGER.debug("Database product: {}", databaseProductName);
            return databaseProductName;
        } catch (SQLException se) {
            LOGGER.warn("Problem determining database product!", se);
            return null;
        }
    }
1072763
static function getParameter($connection_name, $key) {
		// don't reveal passwords through this interface
		if ('password' === $key) {
			throw new RuntimeException('DB::password is private');
		}

		if (!array_key_exists($connection_name, self::$parameters)) {
			throw new RuntimeException("Configuration for database '$connection_name' not loaded");
		}

		return @self::$parameters[$connection_name][$key];
	}