本文整理汇总了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;
}
示例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();
}
}
示例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();
}
}