/** * In some cases, it is desirable to immediately release a Connection's * database and JDBC resources instead of waiting for them to be * automatically released. * * <B>Note:</B> A Connection is automatically closed when it is * garbage collected. Certain fatal errors also result in a closed * connection. * * @exception SQLException if a database access error occurs */ public void close() { protoConnection.close(); openStackTrace = null; }
public String getCatalog() throws SQLException { checkClosed(); return protoConnection.getDatabase(); }
public Encoding getEncoding() { return protoConnection.getEncoding(); }
private void runInitialQueries(ProtocolConnection protoConnection, Properties info, Logger logger) throws SQLException { String dbVersion = protoConnection.getServerVersion(); if (dbVersion.compareTo("9.0") >= 0) { SetupQueryRunner.run(protoConnection, "SET extra_float_digits = 3", false); } String appName = info.getProperty("ApplicationName"); if (appName != null && dbVersion.compareTo("9.0") >= 0) { StringBuffer sql = new StringBuffer(); sql.append("SET application_name = '"); Utils.appendEscapedLiteral(sql, appName, protoConnection.getStandardConformingStrings()); sql.append("'"); SetupQueryRunner.run(protoConnection, sql.toString(), false); } }
public int getTransactionState() { return protoConnection.getTransactionState(); }
public boolean getStandardConformingStrings() { return protoConnection.getStandardConformingStrings(); }
public QueryExecutor getQueryExecutor() { return protoConnection.getQueryExecutor(); }
public int getProtocolVersion() { return protoConnection.getProtocolVersion(); }
public String getUserName() throws SQLException { return protoConnection.getUser(); }
public PGNotification[] getNotifications() throws SQLException { checkClosed(); getQueryExecutor().processNotifies(); // Backwards-compatibility hand-holding. PGNotification[] notifications = protoConnection.getNotifications(); return (notifications.length == 0 ? null : notifications); }
this.dbVersionNumber = protoConnection.getServerVersion(); this.compatible = info.getProperty("compatible", Driver.MAJORVERSION + "." + Driver.MINORVERSION);
V2Query(String query, boolean withParameters, ProtocolConnection pconn) { useEStringSyntax = pconn.getServerVersion() != null && pconn.getServerVersion().compareTo("8.1") > 0; boolean stdStrings = pconn.getStandardConformingStrings();
public void commit() throws SQLException { checkClosed(); if (autoCommit) throw new PSQLException(GT.tr("Cannot commit when autoCommit is enabled."), PSQLState.NO_ACTIVE_SQL_TRANSACTION); if (protoConnection.getTransactionState() != ProtocolConnection.TRANSACTION_IDLE) executeTransactionCommand(commitQuery); }
public String escapeString(String str) throws SQLException { return Utils.appendEscapedLiteral(null, str, protoConnection.getStandardConformingStrings()).toString(); }
public static byte[][] run(ProtocolConnection protoConnection, String queryString, boolean wantResults) throws SQLException { QueryExecutor executor = protoConnection.getQueryExecutor(); Query query = executor.createSimpleQuery(queryString); SimpleResultHandler handler = new SimpleResultHandler(protoConnection); int flags = QueryExecutor.QUERY_ONESHOT | QueryExecutor.QUERY_SUPPRESS_BEGIN; if (!wantResults) flags |= QueryExecutor.QUERY_NO_RESULTS | QueryExecutor.QUERY_NO_METADATA; try { executor.execute(query, null, handler, 0, 0, flags); } finally { query.close(); } if (!wantResults) return null; Vector tuples = handler.getResults(); if (tuples == null || tuples.size() != 1) throw new PSQLException(GT.tr("An unexpected result was returned by a query."), PSQLState.CONNECTION_UNABLE_TO_CONNECT); return (byte[][]) tuples.elementAt(0); }
public int getProtocolVersion() { return protoConnection.getProtocolVersion(); }
public String getUserName() throws SQLException { return protoConnection.getUser(); }
public PGNotification[] getNotifications() throws SQLException { getQueryExecutor().processNotifies(); // Backwards-compatibility hand-holding. PGNotification[] notifications = protoConnection.getNotifications(); return (notifications.length == 0 ? null : notifications); }
this.dbVersionNumber = protoConnection.getServerVersion(); this.compatible = info.getProperty("compatible", Driver.MAJORVERSION + "." + Driver.MINORVERSION);
private void runInitialQueries(ProtocolConnection protoConnection, Properties info, Logger logger) throws SQLException { String dbVersion = protoConnection.getServerVersion(); if (dbVersion.compareTo("9.0") >= 0) { SetupQueryRunner.run(protoConnection, "SET extra_float_digits = 3", false); } String appName = info.getProperty("ApplicationName"); if (appName != null && dbVersion.compareTo("9.0") >= 0) { StringBuffer sql = new StringBuffer(); sql.append("SET application_name = '"); Utils.appendEscapedLiteral(sql, appName, protoConnection.getStandardConformingStrings()); sql.append("'"); SetupQueryRunner.run(protoConnection, sql.toString(), false); } }