|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.h2.server.pg.PgServer
public class PgServer
This class implements a subset of the PostgreSQL protocol as described here: http://developer.postgresql.org/pgdocs/postgres/protocol.html The PostgreSQL catalog is described here: http://www.postgresql.org/docs/7.4/static/catalogs.html
Field Summary | |
---|---|
static int |
DEFAULT_PORT
The default port to use for the PG server. |
static int |
PG_TYPE_BOOL
|
static int |
PG_TYPE_BPCHAR
|
static int |
PG_TYPE_BYTEA
|
static int |
PG_TYPE_DATE
|
static int |
PG_TYPE_FLOAT4
|
static int |
PG_TYPE_FLOAT8
|
static int |
PG_TYPE_INT2
|
static int |
PG_TYPE_INT2VECTOR
The integer array type (for the column pg_index.indkey). |
static int |
PG_TYPE_INT4
|
static int |
PG_TYPE_INT8
|
static int |
PG_TYPE_NUMERIC
|
static int |
PG_TYPE_OID
|
static int |
PG_TYPE_TEXT
|
static int |
PG_TYPE_TEXTARRAY
|
static int |
PG_TYPE_TIME
|
static int |
PG_TYPE_TIMESTAMP_NO_TMZONE
|
static int |
PG_TYPE_UNKNOWN
|
static int |
PG_TYPE_VARCHAR
The VARCHAR type. |
Constructor Summary | |
---|---|
PgServer()
|
Method Summary | |
---|---|
java.lang.String |
checkKeyAndGetDatabaseName(java.lang.String db)
If no key is set, return the original database name. |
static int |
convertType(int type)
Convert the SQL type to a PostgreSQL type |
static java.lang.String |
formatType(java.sql.Connection conn,
int pgType,
int typeMod)
Check if the current session has access to this table. |
boolean |
getAllowOthers()
Check if remote connections are allowed. |
static java.lang.String |
getCurrentSchema(java.sql.Connection conn)
Get the name of the current schema. |
static int |
getCurrentTid(java.lang.String table,
java.lang.String id)
Get the current transaction id. |
static java.lang.String |
getEncodingName(int code)
Get the name of this encoding code. |
static java.lang.String |
getIndexColumn(java.sql.Connection conn,
int indexId,
java.lang.Integer ordinalPosition,
java.lang.Boolean pretty)
The Java implementation of the PostgreSQL function pg_get_indexdef. |
java.lang.String |
getName()
Get the human readable name of the service. |
static int |
getOid(java.sql.Connection conn,
java.lang.String tableName)
Get the OID of an object. |
static java.lang.String |
getPgExpr(java.lang.String exprText,
int relationOid)
A fake wrapper around pg_get_expr(expr_text, relation_oid), in PostgreSQL it "decompiles the internal form of an expression, assuming that any vars in it refer to the relation indicated by the second parameter". |
int |
getPort()
Gets the port this service is listening on. |
static java.sql.Timestamp |
getStartTime()
Get the current system time. |
java.lang.String |
getType()
Get the human readable short name of the service. |
java.lang.String |
getURL()
Get the URL of this service in a human readable form |
static java.lang.String |
getUserById(java.sql.Connection conn,
int id)
Get the user name for this id. |
static java.lang.String |
getVersion()
Get the version. |
static boolean |
hasDatabasePrivilege(int id,
java.lang.String privilege)
Check if the this session has the given database privilege. |
static boolean |
hasTablePrivilege(java.lang.String table,
java.lang.String privilege)
Check if the current session has access to this table. |
void |
init(java.lang.String... args)
Initialize the service from command line options. |
boolean |
isDaemon()
Check if a daemon thread should be used. |
boolean |
isRunning(boolean traceError)
Check if the service is running. |
void |
listen()
Listen for incoming connections. |
void |
start()
Start the service. |
void |
stop()
Stop the service. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_PORT
public static final int PG_TYPE_VARCHAR
public static final int PG_TYPE_INT2VECTOR
public static final int PG_TYPE_BOOL
public static final int PG_TYPE_BYTEA
public static final int PG_TYPE_BPCHAR
public static final int PG_TYPE_INT8
public static final int PG_TYPE_INT2
public static final int PG_TYPE_INT4
public static final int PG_TYPE_TEXT
public static final int PG_TYPE_OID
public static final int PG_TYPE_FLOAT4
public static final int PG_TYPE_FLOAT8
public static final int PG_TYPE_UNKNOWN
public static final int PG_TYPE_TEXTARRAY
public static final int PG_TYPE_DATE
public static final int PG_TYPE_TIME
public static final int PG_TYPE_TIMESTAMP_NO_TMZONE
public static final int PG_TYPE_NUMERIC
Constructor Detail |
---|
public PgServer()
Method Detail |
---|
public void init(java.lang.String... args)
Service
init
in interface Service
args
- the command line optionspublic java.lang.String getURL()
Service
getURL
in interface Service
public int getPort()
Service
getPort
in interface Service
public void start()
Service
start
in interface Service
public void listen()
Service
listen
in interface Service
public void stop()
Service
stop
in interface Service
public boolean isRunning(boolean traceError)
Service
isRunning
in interface Service
traceError
- if errors should be written
public boolean getAllowOthers()
Service
getAllowOthers
in interface Service
public java.lang.String getType()
Service
getType
in interface Service
public java.lang.String getName()
Service
getName
in interface Service
public static java.lang.String getIndexColumn(java.sql.Connection conn, int indexId, java.lang.Integer ordinalPosition, java.lang.Boolean pretty) throws java.sql.SQLException
conn
- the connectionindexId
- the index idordinalPosition
- the ordinal position (null if the SQL statement
should be returned)pretty
- this flag is ignored
java.sql.SQLException
public static java.lang.String getCurrentSchema(java.sql.Connection conn) throws java.sql.SQLException
conn
- the connection
java.sql.SQLException
public static int getOid(java.sql.Connection conn, java.lang.String tableName) throws java.sql.SQLException
conn
- the connectiontableName
- the table name
java.sql.SQLException
public static java.lang.String getEncodingName(int code)
code
- the encoding code
public static java.lang.String getVersion()
public static java.sql.Timestamp getStartTime()
public static java.lang.String getUserById(java.sql.Connection conn, int id) throws java.sql.SQLException
conn
- the connectionid
- the user id
java.sql.SQLException
public static boolean hasDatabasePrivilege(int id, java.lang.String privilege)
id
- the session idprivilege
- the privilege to check
public static boolean hasTablePrivilege(java.lang.String table, java.lang.String privilege)
table
- the table nameprivilege
- the privilege to check
public static int getCurrentTid(java.lang.String table, java.lang.String id)
table
- the table nameid
- the id
public static java.lang.String getPgExpr(java.lang.String exprText, int relationOid)
exprText
- the expression textrelationOid
- the relation object id
public static java.lang.String formatType(java.sql.Connection conn, int pgType, int typeMod) throws java.sql.SQLException
conn
- the connectionpgType
- the PostgreSQL type oidtypeMod
- the type modifier (typically -1)
java.sql.SQLException
public static int convertType(int type)
type
- the SQL type
public java.lang.String checkKeyAndGetDatabaseName(java.lang.String db)
db
- the key to test (or database name if no key is used)
DbException
- if a key is set but doesn't matchpublic boolean isDaemon()
Service
isDaemon
in interface Service
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |