识别JDBC驱动名

@param conn 数据库连接对象
@return 驱动
@throws DbRuntimeException SQL异常包装，获取元数据信息失败
546810
public static String identifyDriver(Connection conn) throws DbRuntimeException {
		String driver = null;
		DatabaseMetaData meta;
		try {
			meta = conn.getMetaData();
			driver = identifyDriver(meta.getDatabaseProductName());
			if (StrUtil.isBlank(driver)) {
				driver = identifyDriver(meta.getDriverName());
			}
		} catch (SQLException e) {
			throw new DbRuntimeException("Identify driver error!", e);
		}

		return driver;
	}
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;
}
584315
protected void openConnection() throws SQLException {
        if (connection == null) {
            try {
                Class.forName(configuration.getJdbcDriver());
            } catch (NullPointerException npe) {
                throw new RuntimeException("error while lookup jdbc driver class. jdbc driver is not configured.", npe);
            } catch (ClassNotFoundException e) {
                throw new RuntimeException("jdbc driver not found", e);
            }

            connection = DriverManager.getConnection(configuration.getJdbcUrl(), configuration.getJdbcUser(),
                    configuration.getJdbcPassword());
            connection.setAutoCommit(false);
        }
    }
410563
public static PreparedStatement prepareStatement(Connection conn, String sql, Object... params) throws SQLException {
		Assert.notBlank(sql, "Sql String must be not blank!");

		sql = sql.trim();
		SqlLog.INSTASNCE.log(sql, params);
		PreparedStatement ps;
		if (StrUtil.startWithIgnoreCase(sql, "insert")) {
			// 插入默认返回主键
			ps = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
		} else {
			ps = conn.prepareStatement(sql);
		}
		return fillParams(ps, params);
	}
232149
public Transaction getTransaction(OTMConnection conn)
    {
        TransactionFactory txFactory = getTransactionFactory();
        Transaction tx = txFactory.getTransactionForConnection(conn);
        tx.setKit(this);
        return tx;
    }
895109
def _conn_string_odbc(self, db_key, instance=None, conn_key=None, db_name=None):
        ''' 
        '''
        if instance:
            dsn, host, username, password, database, driver = self._get_access_info(instance, db_key, db_name)
        elif conn_key:
            dsn, host, username, password, database, driver = conn_key.split(":")

        conn_str = ''
        if dsn:
            conn_str = 'DSN={};'.format(dsn)

        if driver:
            conn_str += 'DRIVER={};'.format(driver)
        if host:
            conn_str += 'Server={};'.format(host)
        if database:
            conn_str += 'Database={};'.format(database)

        if username:
            conn_str += 'UID={};'.format(username)
        self.log.debug("Connection string (before password) {}".format(conn_str))
        if password:
            conn_str += 'PWD={};'.format(password)
        return conn_str
144128
protected PreparedStatement createStatment(Connection conn, Sql sql) throws SQLException {

		if (sql == null) {
			throw new NullPointerException("Sql Object is NULL");
		}
		String sqlBody = sql.getSql();

		if (StringUtils.isNotEmpty(sqlBody)) {
			PreparedStatement stmt = null;
			if (sql.isProcedure()) {
				stmt = conn.prepareCall("{" + sqlBody + "}");
			} else if (sql.isPreperStatement()) {
				stmt = conn.prepareStatement(sqlBody);
			}
			
			if (stmt != null) {
				Map<Integer, Object> prepareValues = sql.getPreperValues();
	
				Set<Integer> indexSet = prepareValues.keySet();
				for (Integer index : indexSet) {
					Object value = prepareValues.get(index);
					if (index != null && value != null) {
						if (value instanceof String) {
							stmt.setString(index, value.toString());
						} else if (value instanceof Integer) {
							stmt.setInt(index, ((Integer) value).intValue());
						} else if (value instanceof Long) {
							stmt.setLong(index, ((Long) value).longValue());
						} else if (value instanceof Double) {
							stmt.setDouble(index, ((Double) value).doubleValue());
						} else if (value instanceof Float) {
							stmt.setFloat(index, ((Float) value).floatValue());
						} else if (value instanceof Short) {
							stmt.setShort(index, ((Short) value).shortValue());
						} else if (value instanceof Byte) {
							stmt.setByte(index, ((Byte) value).byteValue());
						} else if (value instanceof Boolean) {
							stmt.setBoolean(index, ((Boolean) value).booleanValue());
						} else if (value instanceof Date) {
							stmt.setDate(index, (Date) value);
						} else if (value instanceof Time) {
							stmt.setTime(index, (Time) value, Calendar.getInstance());
						} else if (value instanceof Blob) {
							stmt.setBlob(index, (Blob) value);
						} else if (value instanceof Clob) {
							stmt.setClob(index, (Clob) value);
						} else if (value instanceof BigDecimal) {
							stmt.setBigDecimal(index, (BigDecimal) value);
						} else if (value instanceof byte[]) {
							stmt.setBytes(index, (byte[]) value);
						} else if (value instanceof Out) {
							if (stmt instanceof CallableStatement) {
								int outType = getProcedureOutType((Out)value);
								if (outType != -999) {
									((CallableStatement)stmt).registerOutParameter(index, outType);
								}
							}
						} else {
							stmt.setObject(index, value);
						}
					}
				}
				return stmt;
			} else {
				return conn.prepareStatement(sqlBody);
			}
		}
378824
private Map<String, Integer> getSlaveStatus(final Connection conn) throws SQLException {
        Map<String, Integer> map = new HashMap<String, Integer>();
        String query = SLAVE_STATUS_QRY;
        Statement statement = null;
        ResultSet rs = null;
        try {
            if (conn != null) {
                statement = conn.createStatement();
                rs = statement.executeQuery(query);
                while (rs.next()) {
                    map.put("Slave_IO_Running", rs.getInt("Slave_IO_Running"));
                    map.put("Slave_SQL_Running", rs.getInt("Slave_SQL_Running"));
                    map.put("Seconds_Behind_Master", rs.getInt("Seconds_Behind_Master"));
                }
            }
        } finally {
            DBUtils.closeQuietly(rs);
            DBUtils.closeQuietly(statement);
        }
        return map;
    }
956963
public static Blob createBlob(final Connection conn) {
		try {
			return conn.createBlob();
		} catch (SQLException e) {
			throw new UroborosqlRuntimeException(e);
		}
	}
861422
public final void closeConnection(final Connection conn) {
        try {
            if (conn != null) {
                conn.close();
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
161566
public void setupJDBCConnection(String strJdbcDriver) throws DBException
    {
        if (m_JDBCConnection != null)
            return;

        if (firstTime == null)
        	firstTime = new Date();
    	if (m_classDB == null)
    	{
	        synchronized (firstTime)
	        {
	        	if (m_classDB == null)
	        		m_classDB = ClassServiceUtility.getClassService().makeObjectFromClassName(strJdbcDriver);
	        }
    	}
        Utility.getLogger().info("Driver found: " + (m_classDB != null));
        m_JDBCConnection = this.getJDBCConnection();    // Setup the initial connection
    }
351428
public function getConnection()
    {
        if (null === $this->conn) {
            $this->checkConfiguration();

            try {
                $this->conn = new SQL(
                    $this->buildDsn(),
                    $this->config['username'],
                    $this->config['password']
                );
            } catch (Exception $e) {
                throw new RuntimeException(static::E_CONNECT);
            }
        }

        return $this->conn;
    }
720563
private int prepareConnectionForBatch(Connection conn) throws SQLException {
        conn.setAutoCommit(false);
        int initialIsolation = Connection.TRANSACTION_REPEATABLE_READ;
        if (_isDB2)
        {
            try
            {
                initialIsolation = conn.getTransactionIsolation();
                if (Connection.TRANSACTION_REPEATABLE_READ != initialIsolation && Connection.TRANSACTION_SERIALIZABLE != initialIsolation)
                {
                    if (tc.isDebugEnabled())
                        Tr.debug(tc, "Transaction isolation level was " + initialIsolation + " , setting to TRANSACTION_REPEATABLE_READ");
                    conn.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
                }
            } catch (Exception e)
            {
                if (tc.isDebugEnabled())
                    Tr.debug(tc, "setTransactionIsolation to RR threw Exception. Transaction isolation level was " + initialIsolation + " ", e);
                FFDCFilter.processException(e, "com.ibm.ws.recoverylog.spi.SQLMultiScopeRecoveryLog.prepareConnectionForBatch", "3668", this);
                if (!isolationFailureReported)
                {
                    isolationFailureReported = true;
                    Tr.warning(tc, "CWRLS0024_EXC_DURING_RECOVERY", e);
                }
                // returning RR will prevent closeConnectionAfterBatch resetting isolation level
                initialIsolation = Connection.TRANSACTION_REPEATABLE_READ;
            }
        }
        return initialIsolation;
    }
332161
function bindAndExecute() {
		$conn = $this->connection;

		if ($conn === null) {
			throw new RuntimeException('bindAndExecute cannot be called on a QueryStatement without a connection.');
		}
		if ($conn instanceof DBMSSQL && $conn->getDriver() === 'dblib' && function_exists('mb_detect_encoding')) {
			return $conn->query($this->__toString());
		}
		if ($conn instanceof DBSQLite) {
			return $conn->query($this->__toString());
		}

		$string = self::embedIdentifiers($this->getString(), array_values($this->identifiers), $conn);

		$result = $conn->prepare($string);
		foreach ($this->getParams() as $key => $value) {
			$pdo_type = PDO::PARAM_STR;
			if (is_int($value)) {
				$pdo_type = PDO::PARAM_INT;
			} elseif (is_null($value)) {
				$pdo_type = PDO::PARAM_NULL;
			} elseif (is_bool($value)) {
				$value = $value ? 1 : 0;
				$pdo_type = PDO::PARAM_INT;
			}
			$result->bindValue($key + 1, $value, $pdo_type);
		}
		$result->execute();
		return $result;
	}
882900
public static NClob createNClob(final Connection conn) {
		try {
			return conn.createNClob();
		} catch (SQLException e) {
			throw new UroborosqlRuntimeException(e);
		}
	}
221094
public static void returnConnection(Connection conn) throws SQLException {
        if (conn == null) {
            return;
        }
        String dsName = openConnDsName.get().get(conn);
        OpenConnStats connStats = dsName != null ? openConnStats.get().get(dsName) : null;
        if (connStats == null) {
            conn.close();
        } else {
            long value = connStats.counter.decrementAndGet();
            if (value <= 0) {
                try {
                    try {
                        if (connStats.inTransaction) {
                            conn.commit();
                        }
                    } catch (Exception e) {
                        conn.rollback();
                    } finally {
                        try {
                            conn.setAutoCommit(true);
                        } finally {
                            connStats.inTransaction = false;
                            conn.close();
                        }
                    }
                } finally {
                    openConnStats.get().remove(dsName);
                    openConnDsName.get().remove(conn);
                }
            }
        }
    }
1291622
private java.sql.Connection connectToDB(String strJDBCDriver, String strJDBCURL,
        String strUsername, String strPassword)
        throws java.sql.SQLException, java.lang.ClassNotFoundException
    {
        Class.forName(strJDBCDriver);
        java.sql.Connection conn =
        java.sql.DriverManager.getConnection(strJDBCURL,
                strUsername, strPassword);  
        return conn;
    }