public void setSchema(String schema) throws SQLException {
    // JDK 1.7
    if (isClosed) {
      throw new SQLException("Connection is closed");
    }
    if (schema == null || schema.isEmpty()) {
      throw new SQLException("Schema name is null or empty");
    }
    if (schema.contains(";")) {
      throw new SQLException("invalid schema name");
    }
    try (Statement stmt = createStatement()) {
      stmt.execute("use " + schema);
    }
  }
Creates a Statement object for sending SQL statements to the database.

@throws SQLException
          if a database access error occurs.
@see java.sql.Connection#createStatement()
jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java