Statement getConnection - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Statement getConnection method.

This code example shows how to use the following methods:getConnection, isClosed
	 * @return true/false 
	 */ 
	public boolean isClosed(){ 
		if(this.statement == null) return true;
		try { 
			if(this.statement.isClosed()) return true;
			if(this.statement.getConnection()==null) return true;
			return false; 
		} 
		catch(SQLException ex){}
		catch(AbstractMethodError ex){}
		return true; 
	} 
	 
	@Override 
	public QueryOption clone() { 
		return new QueryOptionJdbcContext(this);
	} 
 
	public String toString() {
6
CodeRank
This code example shows how to use the following methods:getConnection
	@Override 
	public Connection getNativeConnectionFromStatement(Statement stmt) throws SQLException {
		if (stmt == null) {
			return null; 
		} 
		return getNativeConnection(stmt.getConnection());
	} 
 
	/** 
	 * Not able to unwrap: return passed-in Statement. 
	 */ 
	@Override 
	public Statement getNativeStatement(Statement stmt) throws SQLException {
		return stmt;
	} 
 
	/** 
	 * Not able to unwrap: return passed-in PreparedStatement. 
	 */ 
	@Override 
6
CodeRank
This code example shows how to use the following methods:close, executeUpdate, getConnection
    	sql += " WHERE name = '" + name + "'";
    	 
        Statement st = null;
    	try { 
    		st = getStatement();
    		return st.executeUpdate(sql);
    	} catch (Exception e) {
    		LOG.error("update channel user count error", e);
    		return -1; 
    		 
    	} finally { 
			try { 
				Connection conn = st.getConnection();
	    		st.close();
	    		conn.close();
			} catch (SQLException e) {
			} 
    	} 
    } 
     
6
CodeRank
This code example shows how to use the following methods:executeUpdate, getConnection
    /** 
     * Generates test data.  
     */ 
    private static void initializeBlobData(Statement stmt)
            throws SQLException {
        Connection con = stmt.getConnection();
        con.setAutoCommit(false);
 
        try { 
            stmt.executeUpdate("drop table BlobTable");
        } catch (SQLException sqle) {
            assertSQLState("42Y55", sqle);
        } 
 
        stmt.executeUpdate("create table BlobTable (dBlob Blob, length int)");
 
        PreparedStatement smallBlobInsert = con
                .prepareStatement("insert into BlobTable values (?,?)");
        // Insert just one record. 
         
5
CodeRank
This code example shows how to use the following methods:close, getConnection, getWarnings
 
    try 
    { 
      if (null != m_Statement)
      { 
        conn = m_Statement.getConnection();
        m_Statement.close();
        m_Statement = null;
      } 
    } 
    catch(Exception e) {}
 
    try 
    { 
      if (conn != null)
      { 
        if (m_HasErrors)  m_ConnectionPool.releaseConnectionOnError(conn);
        else m_ConnectionPool.releaseConnection(conn);
//        if (flushConnPool)  m_ConnectionPool.freeUnused(); 
      } 

5
CodeRank
This code example shows how to use the following methods:setBlob, getConnection
 
	@Override 
	public void setBlobAsBytes(PreparedStatement ps, int paramIndex, byte[] content)
			throws SQLException {
 
		Blob blob = ps.getConnection().createBlob();
		blob.setBytes(1, content);
 
		this.temporaryBlobs.add(blob);
		ps.setBlob(paramIndex, blob);
 
		if (logger.isDebugEnabled()) {
			logger.debug(content != null ? "Copied bytes into temporary BLOB with length " + content.length :
					"Set BLOB to null"); 
		} 
	} 
 
	@Override 
	public void setBlobAsBinaryStream( 
			PreparedStatement ps, int paramIndex, InputStream binaryStream, int contentLength)
7
CodeRank
This code example shows how to use the following methods:getConnection, isClosed
	 * @return true/false 
	 */ 
	public boolean isClosed(){ 
		if(this.statement == null) return true;
		try { 
			if(this.statement.isClosed()) return true;
			if(this.statement.getConnection()==null) return true;
			return false; 
		} 
		catch(SQLException ex){}
		catch(AbstractMethodError ex){}
		return true; 
	} 
	 
	@Override 
	public QueryOption clone() { 
		return new QueryOptionJdbcContext(this);
	} 
 
	public String toString() {
5
CodeRank
This code example shows how to use the following methods:getConnection
        delegate.clearBatch();
    } 
 
    @Override 
    public Connection getConnection() throws SQLException {
        return delegate.getConnection();
    } 
 
    @Override 
    public boolean getMoreResults(int current) throws SQLException {
        return delegate.getMoreResults(current);
    } 
 
    @Override 
    public ResultSet getGeneratedKeys() throws SQLException {
        return delegate.getGeneratedKeys();
    } 
 
    @Override 
    public int getResultSetHoldability() throws SQLException {
5
CodeRank
This code example shows how to use the following methods:getObject, getConnection
     * Spring Framework during the out parameter processing and it's not accessed by appplication 
     * code directly. 
     */ 
    public Object getTypeValue(CallableStatement cs, int paramIndex, int sqlType, String typeName)
            throws SQLException {
        Connection con = cs.getConnection();
        Map<String, Class<?>> typeMap = con.getTypeMap();
        typeMap.put(typeName, targetClass);
        Object o = cs.getObject(paramIndex);
        return o; 
    } 
} 
4
CodeRank
This code example shows how to use the following methods:getConnection
  public int[] executeBatch() throws SQLException {
    return delegate.executeBatch();
  } 
 
  public Connection getConnection() throws SQLException {
    return delegate.getConnection();
  } 
 
  public boolean getMoreResults(int current) throws SQLException {
    return delegate.getMoreResults(current);
  } 
 
  public ResultSet getGeneratedKeys() throws SQLException {
    return delegate.getGeneratedKeys();
  } 
 
  public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
    return delegate.executeUpdate(sql, autoGeneratedKeys);
  } 
 
4
CodeRank
getConnection Method Overview
Retrieves the Connection object that produced this Statement object.
See Code Examples for other Java 8 Statement Methods: