當前位置: 首頁>>代碼示例>>Java>>正文


Java Statement.getConnection方法代碼示例

本文整理匯總了Java中java.sql.Statement.getConnection方法的典型用法代碼示例。如果您正苦於以下問題:Java Statement.getConnection方法的具體用法?Java Statement.getConnection怎麽用?Java Statement.getConnection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.sql.Statement的用法示例。


在下文中一共展示了Statement.getConnection方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getPostgreSqlnputStream

import java.sql.Statement; //導入方法依賴的package包/類
/**
    * Extract the Large Object Input Stream from PostgreSQL
    * 
    * @param resultSet
    *            the Result Set to extract the blob from
    * @param columnIndex
    *            the index of column
    * @return the Large Object Input Stream from PostgreSQL
    * @throws SQLException
    */
   public static InputStream getPostgreSqlnputStream(ResultSet resultSet,
    int columnIndex) throws SQLException {
InputStream in;
Statement statement = resultSet.getStatement();
Connection conn = statement.getConnection();

// Get the Large Object Manager to perform operations with
LargeObjectManager lobj = ((org.postgresql.PGConnection) conn)
	.getLargeObjectAPI();
long oid = resultSet.getLong(columnIndex);

if (oid < 1) {
    return null;
}

LargeObject obj = lobj.open(oid, LargeObjectManager.READ);

in = obj.getInputStream();
return in;
   }
 
開發者ID:kawansoft,項目名稱:aceql-http,代碼行數:31,代碼來源:PostgreSqlUtil.java

示例2: close

import java.sql.Statement; //導入方法依賴的package包/類
/**
 * Close connection
 *
 * @param rs
 */
public static void close(ResultSet rs) {
    Statement st = null;
    Connection con = null;
    try {
        try {
            if (rs != null) {
                st = rs.getStatement();
                rs.close();
            }
        } finally {
            try {
                if (st != null) {
                    con = st.getConnection();
                    st.close();
                }
            } finally {
                if (con != null) {
                    con.close();
                }
            }
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
 
開發者ID:warlock-china,項目名稱:azeroth,代碼行數:31,代碼來源:JDBCUtils.java

示例3: getDatabaseProductName

import java.sql.Statement; //導入方法依賴的package包/類
/**
    * Returns true if engine is terradata
    * 
    * @param resultSet
    *            the result set in use
    * @returns true if engine is terradata
    * @throws SQLException
    */
   private String getDatabaseProductName(ResultSet resultSet)
    throws SQLException {

Statement statement = resultSet.getStatement();

// happens on Metadata requests, we don' care about the result:
if (statement == null) {
    return "unknown";
} else {
    Connection connection = statement.getConnection();
    return new SqlUtil(connection).getDatabaseProductName();
}
   }
 
開發者ID:kawansoft,項目名稱:aceql-http,代碼行數:22,代碼來源:ResultSetWriter.java


注:本文中的java.sql.Statement.getConnection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。