Best code examples for Java 8 Connection class (java.sql.Connection)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Connection class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Java 8 Connection examples from Open Source projects
This code example shows how to use the following methods: close
    } 
 
    public void tearDown() throws Exception { 
        deleteTestTables(); 
        statement.close();
        conn.close();
        super.tearDown(); 
    } 
 
    private void createTestTables() { 
        try { 
            DatabaseMetaData meta = conn.getMetaData();
            ResultSet userTab = meta.getTables(null, null, null, null);
 
            while (userTab.next()) {
                String tableName = userTab.getString("TABLE_NAME");
                if (tableName.equals(DatabaseCreator.PARENT_TABLE)) {
                    statement
                            .execute(DatabaseCreator.DROP_TABLE_PARENT);
                } else if (tableName
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: createStatement
	public void close() throws SQLException { 
		conn.close();
	} 
 
	public ResultSet executeQuery(String sql) throws SQLException {
		Statement stat = conn.createStatement();
		ResultSet rs = stat.executeQuery(sql);
		return rs;
	} 
 
	public int executeUpdate(String sql) throws SQLException {
		Statement stat = conn.createStatement();
		int affected_num = stat.executeUpdate(sql);
 
		if (stat != null) {
			stat.close();
		} 
		return affected_num;
	} 
} 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: close
  { 
    try 
    { 
      if(target != null)
      { 
        target.close();
      } 
    } 
    catch(SQLException ex)
    { 
      // Ignore this 
    } 
  } 
 
} 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: close, prepareStatement
 
        try { 
            checkSystemVm(conn);
        } finally { 
            try { 
                conn.close();
            } catch (SQLException e) {
            } 
        } 
    } 
 
    protected void checkSystemVm(Connection conn) throws SQLException {
        PreparedStatement pstmt;
 
        pstmt = conn
                .prepareStatement("SELECT version FROM `cloud`.`version` ORDER BY id DESC LIMIT 1");
        ResultSet rs = pstmt.executeQuery();
        assert rs.next() : "No version selected";
        assert rs.getString(1).equals("3.0.0") : "VERSION stored is not 3.0.0: "
                + rs.getString(1);

8
CodeRank
This code example shows how to use the following methods: close, commit, rollback
     
    /** {@inheritDoc} */ 
    public void close(TaskAttemptContext context) throws IOException {
      try { 
        statement.executeBatch();
        connection.commit();
      } catch (SQLException e) {
        try { 
          connection.rollback();
        } 
        catch (SQLException ex) {
          LOG.warn(StringUtils.stringifyException(ex));
        } 
        throw new IOException(e.getMessage());
      } finally { 
        try { 
          statement.close();
          connection.close();
        } 
        catch (SQLException ex) {

8
CodeRank
Related Java 8 Connection Questions & Answers:
See Code Examples for Java 8 Connection Methods: