Class PgServer
java.lang.Object
org.h2.server.pg.PgServer
- All Implemented Interfaces:
Service
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate Stringstatic final intThe default port to use for the PG server.private booleanprivate booleanprivate Stringprivate Stringstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intThe VARCHAR type.static final intprivate final AtomicIntegerprivate intprivate booleanprivate final Set<PgServerThread> private ServerSocketprivate booleanprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanIf no key is set, return the original database name.(package private) voidcheckType(int type) Check whether a data type is supported.static intconvertType(TypeInfo type) Convert the SQL type to a PostgreSQL typestatic StringformatType(int pgType) Returns the name of the given type.booleanCheck if remote connections are allowed.(package private) String(package private) booleangetName()Get the human readable name of the service.intgetPort()Gets the port this service is listening on.(package private) PgServerThreadgetThread(int processId) Get the thread with the given process id.(package private) booleangetTrace()getType()Get the human readable short name of the service.Get the type hash set.getURL()Get the URL of this service in a human readable formvoidInitialize the service from command line options.booleanisDaemon()Check if a daemon thread should be used.booleanisRunning(boolean traceError) Check if the service is running.voidlisten()Listen for incoming connections.(package private) voidRemove a thread from the list.voidstart()Start the service.voidstop()Stop the service.(package private) voidPrint a message if the trace flag is enabled.(package private) voidPrint the stack trace if the trace flag is enabled.
-
Field Details
-
DEFAULT_PORT
public static final int DEFAULT_PORTThe default port to use for the PG server. This value is also in the documentation and in the Server javadoc.- See Also:
-
PG_TYPE_VARCHAR
public static final int PG_TYPE_VARCHARThe VARCHAR type.- See Also:
-
PG_TYPE_BOOL
public static final int PG_TYPE_BOOL- See Also:
-
PG_TYPE_BYTEA
public static final int PG_TYPE_BYTEA- See Also:
-
PG_TYPE_BPCHAR
public static final int PG_TYPE_BPCHAR- See Also:
-
PG_TYPE_INT8
public static final int PG_TYPE_INT8- See Also:
-
PG_TYPE_INT2
public static final int PG_TYPE_INT2- See Also:
-
PG_TYPE_INT4
public static final int PG_TYPE_INT4- See Also:
-
PG_TYPE_TEXT
public static final int PG_TYPE_TEXT- See Also:
-
PG_TYPE_FLOAT4
public static final int PG_TYPE_FLOAT4- See Also:
-
PG_TYPE_FLOAT8
public static final int PG_TYPE_FLOAT8- See Also:
-
PG_TYPE_UNKNOWN
public static final int PG_TYPE_UNKNOWN- See Also:
-
PG_TYPE_INT2_ARRAY
public static final int PG_TYPE_INT2_ARRAY- See Also:
-
PG_TYPE_INT4_ARRAY
public static final int PG_TYPE_INT4_ARRAY- See Also:
-
PG_TYPE_VARCHAR_ARRAY
public static final int PG_TYPE_VARCHAR_ARRAY- See Also:
-
PG_TYPE_DATE
public static final int PG_TYPE_DATE- See Also:
-
PG_TYPE_TIME
public static final int PG_TYPE_TIME- See Also:
-
PG_TYPE_TIMETZ
public static final int PG_TYPE_TIMETZ- See Also:
-
PG_TYPE_TIMESTAMP
public static final int PG_TYPE_TIMESTAMP- See Also:
-
PG_TYPE_TIMESTAMPTZ
public static final int PG_TYPE_TIMESTAMPTZ- See Also:
-
PG_TYPE_NUMERIC
public static final int PG_TYPE_NUMERIC- See Also:
-
typeSet
-
port
private int port -
portIsSet
private boolean portIsSet -
stop
private boolean stop -
trace
private boolean trace -
serverSocket
-
running
-
pid
-
baseDir
-
allowOthers
private boolean allowOthers -
isDaemon
private boolean isDaemon -
ifExists
private boolean ifExists -
key
-
keyDatabase
-
-
Constructor Details
-
PgServer
public PgServer()
-
-
Method Details
-
init
-
getTrace
boolean getTrace() -
trace
-
remove
-
traceError
Print the stack trace if the trace flag is enabled.- Parameters:
e- the exception
-
getURL
-
getPort
-
allow
-
start
-
listen
-
stop
-
isRunning
-
getThread
Get the thread with the given process id.- Parameters:
processId- the process id- Returns:
- the thread
-
getBaseDir
String getBaseDir() -
getAllowOthers
public boolean getAllowOthers()Description copied from interface:ServiceCheck if remote connections are allowed.- Specified by:
getAllowOthersin interfaceService- Returns:
- true if remote connections are allowed
-
getType
-
getName
-
getIfExists
boolean getIfExists() -
formatType
Returns the name of the given type.- Parameters:
pgType- the PostgreSQL type oid- Returns:
- the name of the given type
-
convertType
Convert the SQL type to a PostgreSQL type- Parameters:
type- the SQL type- Returns:
- the PostgreSQL type
-
getTypeSet
-
checkType
void checkType(int type) Check whether a data type is supported. A warning is logged if not.- Parameters:
type- the type
-
checkKeyAndGetDatabaseName
If no key is set, return the original database name. If a key is set, check if the key matches. If yes, return the correct database name. If not, throw an exception.- Parameters:
db- the key to test (or database name if no key is used)- Returns:
- the database name
- Throws:
DbException- if a key is set but doesn't match
-
isDaemon
-