private SQLException receiveErrorResponse() throws IOException { // it's possible to get more than one error message for a query // see libpq comments wrt backend closing a connection // so, append messages to a string buffer and keep processing // check at the bottom to see if we need to throw an exception int elen = pgStream.ReceiveInteger4(); String totalMessage = pgStream.ReceiveString(elen - 4); ServerErrorMessage errorMsg = new ServerErrorMessage(totalMessage, logger.getLogLevel()); if (logger.logDebug()) logger.debug(" <=BE ErrorMessage(" + errorMsg.toString() + ")"); return new PSQLException(errorMsg); }
public void info(String str) { info(str, null); }
logger = new Logger(nextConnectionID++); logger.setLogLevel(logLevel); if (logger.logInfo()) logger.info(Driver.getVersion()); this.compatible = info.getProperty("compatible", Driver.MAJORVERSION + "." + Driver.MINORVERSION); if (logger.logDebug()) logger.debug(" compatible = " + compatible); logger.debug(" loglevel = " + logLevel); logger.debug(" prepare threshold = " + prepareThreshold);
/**** XAConnection interface ****/ public Connection getConnection() throws SQLException { if (logger.logDebug()) debug("PGXAConnection.getConnection called"); Connection conn = super.getConnection(); // When we're outside an XA transaction, autocommit // is supposed to be true, per usual JDBC convention. // When an XA transaction is in progress, it should be // false. if(state == STATE_IDLE) conn.setAutoCommit(true); /* * Wrap the connection in a proxy to forbid application from * fiddling with transaction state directly during an XA transaction */ ConnectionHandler handler = new ConnectionHandler(conn); return (Connection)Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Connection.class, PGConnection.class}, handler); }
public void debug(String str) { debug(str, null); }
protected void finalize() throws Throwable { if (openStackTrace != null) logger.log(GT.tr("Finalizing a Connection that was never closed:"), openStackTrace); close(); }
public static int getLogLevel() { synchronized (Driver.class) { return logger.getLogLevel(); } }
/** * used to turn logging on to a certain level, can be called * by specifying fully qualified class ie org.postgresql.Driver.setLogLevel() * @param logLevel sets the level which logging will respond to * INFO being almost no messages * DEBUG most verbose */ public static void setLogLevel(int logLevel) { synchronized (Driver.class) { logger.setLogLevel(logLevel); logLevelSet = true; } }
logger = new Logger(nextConnectionID++); logger.setLogLevel(logLevel); if (logger.logInfo()) logger.info(Driver.getVersion()); this.compatible = info.getProperty("compatible", Driver.MAJORVERSION + "." + Driver.MINORVERSION); if (logger.logDebug()) logger.debug(" compatible = " + compatible); logger.debug(" loglevel = " + logLevel); logger.debug(" prepare threshold = " + prepareThreshold);
public void commit(Xid xid, boolean onePhase) throws XAException { if (logger.logDebug()) debug("committing xid = " + xid + (onePhase ? " (one phase) " : " (two phase)")); if (xid == null) throw new PGXAException(GT.tr("xid must not be null"), XAException.XAER_INVAL); if (onePhase) commitOnePhase(xid); else commitPrepared(xid); }
private void debug(String s) { logger.debug("XAResource " + Integer.toHexString(this.hashCode()) + ": " + s); }
protected void finalize() throws Throwable { if (openStackTrace != null) logger.log(GT.tr("Finalizing a Connection that was never closed:"), openStackTrace); close(); }
public static int getLogLevel() { synchronized (Driver.class) { return logger.getLogLevel(); } }