Codota Logo
PgConnection.createStatement
Code IndexAdd Codota to your IDE (free)

How to use
createStatement
method
in
org.postgresql.jdbc.PgConnection

Best Java code snippets using org.postgresql.jdbc.PgConnection.createStatement (Showing top 20 results out of 315)

  • Common ways to obtain PgConnection
private void myMethod () {
PgConnection p =
  • Codota IconConnection connection;connection.unwrap(PgConnection.class)
  • Smart code suggestions by Codota
}
origin: org.postgresql/postgresql

protected Statement createMetaDataStatement() throws SQLException {
 return connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
   ResultSet.CONCUR_READ_ONLY);
}
origin: org.postgresql/postgresql

@Override
public Statement createStatement() throws SQLException {
 // We now follow the spec and default to TYPE_FORWARD_ONLY.
 return createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
}
origin: org.postgresql/postgresql

public String getSchema() throws SQLException {
 checkClosed();
 Statement stmt = createStatement();
 try {
  ResultSet rs = stmt.executeQuery("select current_schema()");
  try {
   if (!rs.next()) {
    return null; // Is it ever possible?
   }
   return rs.getString(1);
  } finally {
   rs.close();
  }
 } finally {
  stmt.close();
 }
}
origin: org.postgresql/postgresql

public void setSchema(String schema) throws SQLException {
 checkClosed();
 Statement stmt = createStatement();
 try {
  if (schema == null) {
   stmt.executeUpdate("SET SESSION search_path TO DEFAULT");
  } else {
   StringBuilder sb = new StringBuilder();
   sb.append("SET SESSION search_path TO '");
   Utils.escapeLiteral(sb, schema, getStandardConformingStrings());
   sb.append("'");
   stmt.executeUpdate(sb.toString());
   LOGGER.log(Level.FINE, "  setSchema = {0}", schema);
  }
 } finally {
  stmt.close();
 }
}
origin: org.postgresql/postgresql

@Override
public Statement createStatement(int resultSetType, int resultSetConcurrency)
  throws SQLException {
 checkClosed();
 return createStatement(resultSetType, resultSetConcurrency, getHoldability());
}
origin: org.postgresql/postgresql

protected int getMaxIndexKeys() throws SQLException {
 if (INDEX_MAX_KEYS == 0) {
  String sql;
  sql = "SELECT setting FROM pg_catalog.pg_settings WHERE name='max_index_keys'";
  Statement stmt = connection.createStatement();
  ResultSet rs = null;
  try {
   rs = stmt.executeQuery(sql);
   if (!rs.next()) {
    stmt.close();
    throw new PSQLException(
      GT.tr(
        "Unable to determine a value for MaxIndexKeys due to missing system catalog data."),
      PSQLState.UNEXPECTED_ERROR);
   }
   INDEX_MAX_KEYS = rs.getInt(1);
  } finally {
   JdbcBlackHole.close(rs);
   JdbcBlackHole.close(stmt);
  }
 }
 return INDEX_MAX_KEYS;
}
origin: org.postgresql/postgresql

protected int getMaxNameLength() throws SQLException {
 if (NAMEDATALEN == 0) {
  String sql;
  sql = "SELECT t.typlen FROM pg_catalog.pg_type t, pg_catalog.pg_namespace n "
     + "WHERE t.typnamespace=n.oid AND t.typname='name' AND n.nspname='pg_catalog'";
  Statement stmt = connection.createStatement();
  ResultSet rs = null;
  try {
   rs = stmt.executeQuery(sql);
   if (!rs.next()) {
    throw new PSQLException(GT.tr("Unable to find name datatype in the system catalogs."),
      PSQLState.UNEXPECTED_ERROR);
   }
   NAMEDATALEN = rs.getInt("typlen");
  } finally {
   JdbcBlackHole.close(rs);
   JdbcBlackHole.close(stmt);
  }
 }
 return NAMEDATALEN - 1;
}
origin: org.postgresql/postgresql

@Override
public Savepoint setSavepoint(String name) throws SQLException {
 checkClosed();
 if (getAutoCommit()) {
  throw new PSQLException(GT.tr("Cannot establish a savepoint in auto-commit mode."),
    PSQLState.NO_ACTIVE_SQL_TRANSACTION);
 }
 PSQLSavepoint savepoint = new PSQLSavepoint(name);
 // Note we can't use execSQLUpdate because we don't want
 // to suppress BEGIN.
 Statement stmt = createStatement();
 stmt.executeUpdate("SAVEPOINT " + savepoint.getPGName());
 stmt.close();
 return savepoint;
}
origin: org.postgresql/postgresql

@Override
public Savepoint setSavepoint() throws SQLException {
 checkClosed();
 String pgName;
 if (getAutoCommit()) {
  throw new PSQLException(GT.tr("Cannot establish a savepoint in auto-commit mode."),
    PSQLState.NO_ACTIVE_SQL_TRANSACTION);
 }
 PSQLSavepoint savepoint = new PSQLSavepoint(savepointId++);
 pgName = savepoint.getPGName();
 // Note we can't use execSQLUpdate because we don't want
 // to suppress BEGIN.
 Statement stmt = createStatement();
 stmt.executeUpdate("SAVEPOINT " + pgName);
 stmt.close();
 return savepoint;
}
origin: org.postgresql/postgresql

Statement statement = createStatement();
statement.execute("IDENTIFY_SYSTEM");
statement.close();
origin: org.postgresql/postgresql

Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
origin: org.postgresql/postgresql

Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
origin: debezium/debezium

try (Statement stmt = pgConnection().createStatement()) {
  stmt.execute(String.format(
      "CREATE_REPLICATION_SLOT %s TEMPORARY LOGICAL %s",
origin: org.postgresql/postgresql

ResultSet rs = null;
try {
 stmt = connection.createStatement();
 rs = stmt.executeQuery(sql);
 if (!rs.next()) {
origin: org.postgresql/postgresql

@Override
public void execSQLUpdate(String s) throws SQLException {
 BaseStatement stmt = (BaseStatement) createStatement();
 if (stmt.executeWithFlags(s, QueryExecutor.QUERY_NO_METADATA | QueryExecutor.QUERY_NO_RESULTS
   | QueryExecutor.QUERY_SUPPRESS_BEGIN)) {
  throw new PSQLException(GT.tr("A result was returned when none was expected."),
    PSQLState.TOO_MANY_RESULTS);
 }
 // Transfer warnings to the connection, since the user never
 // has a chance to see the statement itself.
 SQLWarning warnings = stmt.getWarnings();
 if (warnings != null) {
  addWarning(warnings);
 }
 stmt.close();
}
origin: org.postgresql/postgresql

Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
            + " WHERE a.attrelid = " + returnTypeRelid
            + " AND NOT a.attisdropped AND a.attnum > 0 ORDER BY a.attnum ";
  Statement columnstmt = connection.createStatement();
  ResultSet columnrs = columnstmt.executeQuery(columnsql);
  while (columnrs.next()) {
origin: org.postgresql/postgresql

  + " ORDER BY a.attnum ";
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
origin: org.postgresql/postgresql

Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
origin: org.postgresql/postgresql

@Override
public ResultSet execSQLQuery(String s, int resultSetType, int resultSetConcurrency)
  throws SQLException {
 BaseStatement stat = (BaseStatement) createStatement(resultSetType, resultSetConcurrency);
 boolean hasResultSet = stat.executeWithFlags(s, QueryExecutor.QUERY_SUPPRESS_BEGIN);
 while (!hasResultSet && stat.getUpdateCount() != -1) {
  hasResultSet = stat.getMoreResults();
 }
 if (!hasResultSet) {
  throw new PSQLException(GT.tr("No results were returned by the query."), PSQLState.NO_DATA);
 }
 // Transfer warnings to the connection, since the user never
 // has a chance to see the statement itself.
 SQLWarning warnings = stat.getWarnings();
 if (warnings != null) {
  addWarning(warnings);
 }
 return stat.getResultSet();
}
origin: org.postgresql/postgresql

   + " WHERE n.nspname  != 'pg_toast'";
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(sql);
org.postgresql.jdbcPgConnectioncreateStatement

Popular methods of PgConnection

  • close
    Note: even though Statement is automatically closed when it is garbage collected, it is better to cl
  • getServerMajorVersion
    Get server major version.
  • addDataType
  • getCopyAPI
  • getEncoding
  • <init>
  • abort
  • addWarning
    This adds a warning to the warning chain.
  • appendArray
  • borrowCallableQuery
  • borrowQuery
  • borrowReturningQuery
  • borrowQuery,
  • borrowReturningQuery,
  • checkClosed,
  • commit,
  • createQuery,
  • createTypeInfo,
  • encodeString,
  • escapeString,
  • execSQLQuery

Popular in Java

  • Running tasks concurrently on multiple threads
  • addToBackStack (FragmentTransaction)
  • getSharedPreferences (Context)
  • requestLocationUpdates (LocationManager)
  • String (java.lang)
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • Pattern (java.util.regex)
    A compiled representation of a regular expression. A regular expression, specified as a string, must
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now