com.caucho.quercus.lib.db
Class Postgres

java.lang.Object
  extended by com.caucho.quercus.lib.db.JdbcConnectionResource
      extended by com.caucho.quercus.lib.db.Postgres
All Implemented Interfaces:
EnvCleanup

public class Postgres
extends JdbcConnectionResource

postgres connection class (postgres has NO object oriented API)


Nested Class Summary
 
Nested classes/interfaces inherited from class com.caucho.quercus.lib.db.JdbcConnectionResource
JdbcConnectionResource.SqlParseToken
 
Field Summary
 
Fields inherited from class com.caucho.quercus.lib.db.JdbcConnectionResource
_conn, _driver, _flags, _host, _port, _socket, _sqlParseToken, _url, ENCODING
 
Constructor Summary
Postgres(Env env, java.lang.String host, java.lang.String user, java.lang.String password, java.lang.String db, int port, java.lang.String driver, java.lang.String url)
           
 
Method Summary
protected  void clearErrors()
          This function is overriden in Postgres to clear any postgres specific server error message
protected  ConnectionEntry connectImpl(Env env, java.lang.String host, java.lang.String userName, java.lang.String password, java.lang.String dbname, int port, java.lang.String socket, int flags, java.lang.String driver, java.lang.String url, boolean isNewLink)
          Connects to the underlying database.
protected  JdbcResultResource createResult(Env env, java.sql.Statement stmt, java.sql.ResultSet rs)
          Creates a database-specific result.
 PostgresResult getAsynchronousResult()
           
 PostgresStatement getAsynchronousStatement()
           
 java.lang.String getClientEncoding()
          Return the "client_encoding" property.
protected  java.lang.Object getServerErrorMessage()
          Return the postgres server specific error message
 PostgresStatement getStatement(java.lang.String name)
           
protected  void keepResourceValues(java.sql.Statement stmt)
          This function is overriden in Postgres to keep result set references for php/430a (see also php/1f33)
protected  boolean keepStatementOpen()
          This function is overriden in Postgres to keep statement references for php/430a
static StringValue pgRealEscapeString(StringValue str)
           
 PostgresStatement prepare(Env env, StringValue query)
          returns a prepared statement
 void putStatement(java.lang.String name, PostgresStatement stmt)
           
 PostgresResult query(Env env, java.lang.String sql)
          Executes a query.
protected  StringValue realEscapeString(StringValue str)
          Escape the given string for SQL statements.
 PostgresStatement removeStatement(java.lang.String name)
           
protected  void saveErrors(java.sql.SQLException e)
          This function is overriden in Postgres to save the postgres specific server error message
 void setAsynchronousResult(PostgresResult asyncResult)
           
 void setAsynchronousStatement(PostgresStatement asyncStmt)
           
 boolean setClientEncoding(java.lang.String encoding)
          Set the "client_encoding" property.
 java.lang.String toString()
          Converts to a string.
 
Methods inherited from class com.caucho.quercus.lib.db.JdbcConnectionResource
cleanup, close, closeStatement, commit, connectInternal, error, getAffectedRows, getCatalog, getCatalogs, getCharacterSetName, getClientInfo, getConnection, getDbName, getDriver, getEnv, getErrorCode, getErrorMessage, getFieldCount, getHost, getHostInfo, getJavaConnection, getPassword, getPort, getResultResource, getServerInfo, getTableMetaData, getUrl, getURL, getUserName, getWarnings, isConnected, isSeekable, parseSqlToken, ping, realQuery, rollback, setAffectedRows, setAutoCommit, setCatalog, setResultResource, setWarnings, toObject, validateConnection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Postgres

public Postgres(Env env,
                java.lang.String host,
                java.lang.String user,
                java.lang.String password,
                java.lang.String db,
                int port,
                java.lang.String driver,
                java.lang.String url)
Method Detail

connectImpl

protected ConnectionEntry connectImpl(Env env,
                                      java.lang.String host,
                                      java.lang.String userName,
                                      java.lang.String password,
                                      java.lang.String dbname,
                                      int port,
                                      java.lang.String socket,
                                      int flags,
                                      java.lang.String driver,
                                      java.lang.String url,
                                      boolean isNewLink)
Connects to the underlying database.

Specified by:
connectImpl in class JdbcConnectionResource

prepare

public PostgresStatement prepare(Env env,
                                 StringValue query)
returns a prepared statement


query

public PostgresResult query(Env env,
                            java.lang.String sql)
Executes a query.

Parameters:
sql - the escaped query string (can contain escape sequences like `\n' and `\Z')
Returns:
a JdbcResultResource, or null for failure

createResult

protected JdbcResultResource createResult(Env env,
                                          java.sql.Statement stmt,
                                          java.sql.ResultSet rs)
Creates a database-specific result.

Overrides:
createResult in class JdbcConnectionResource

setAsynchronousResult

public void setAsynchronousResult(PostgresResult asyncResult)

getAsynchronousResult

public PostgresResult getAsynchronousResult()

getAsynchronousStatement

public PostgresStatement getAsynchronousStatement()

setAsynchronousStatement

public void setAsynchronousStatement(PostgresStatement asyncStmt)

putStatement

public void putStatement(java.lang.String name,
                         PostgresStatement stmt)

getStatement

public PostgresStatement getStatement(java.lang.String name)

removeStatement

public PostgresStatement removeStatement(java.lang.String name)

keepResourceValues

protected void keepResourceValues(java.sql.Statement stmt)
This function is overriden in Postgres to keep result set references for php/430a (see also php/1f33)

Overrides:
keepResourceValues in class JdbcConnectionResource

keepStatementOpen

protected boolean keepStatementOpen()
This function is overriden in Postgres to keep statement references for php/430a

Overrides:
keepStatementOpen in class JdbcConnectionResource

pgRealEscapeString

public static StringValue pgRealEscapeString(StringValue str)

realEscapeString

protected StringValue realEscapeString(StringValue str)
Escape the given string for SQL statements.

Overrides:
realEscapeString in class JdbcConnectionResource
Parameters:
str - a string
Returns:
the string escaped for SQL statements

clearErrors

protected void clearErrors()
This function is overriden in Postgres to clear any postgres specific server error message

Overrides:
clearErrors in class JdbcConnectionResource

saveErrors

protected void saveErrors(java.sql.SQLException e)
This function is overriden in Postgres to save the postgres specific server error message

Overrides:
saveErrors in class JdbcConnectionResource

getServerErrorMessage

protected java.lang.Object getServerErrorMessage()
Return the postgres server specific error message


toString

public java.lang.String toString()
Description copied from class: JdbcConnectionResource
Converts to a string.

Overrides:
toString in class JdbcConnectionResource

getClientEncoding

public java.lang.String getClientEncoding()
Return the "client_encoding" property. This is the encoding the JDBC driver uses to read character data from the server. The JDBC driver used to let the user change the encoding, but it now fails on any attempt to set the encoding to anything other than UNICODE.

Overrides:
getClientEncoding in class JdbcConnectionResource

setClientEncoding

public boolean setClientEncoding(java.lang.String encoding)
Set the "client_encoding" property. This is a no-op for the JDBC driver because it only supports UNICODE as the client encoding. Return true to indicate success in all cases.

Overrides:
setClientEncoding in class JdbcConnectionResource