public class PostgreSQLConnector extends DatabaseConnector
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DATABASE_DESCRIPTION
The name of the represented database management system.
|
static java.lang.String |
DATABASE_NAME
The name of the represented database management system.
|
static java.lang.String |
DRIVER_DISPLAY_NAME
SQL driver display name (client/server mode).
|
static java.lang.String |
DRIVER_NAME
SQL driver class name (client/server mode).
|
static java.net.URL |
ICON_POSTGRESQL
Default icon for the connector.
|
cacheSchemaByTable, CONNECT_AUTH_REQUIRED, CONNECT_FAILED, CONNECT_SUCCESS, databaseDescription, databaseName, dbManager, defaultConn, defaultConnURL, driverDisplayName, driverName, driverProductName, driverProductVersion, params, pool, schemaMappings, typeConfig
Constructor and Description |
---|
PostgreSQLConnector()
Constructor method for i18n purposes only.
|
PostgreSQLConnector(java.util.Properties params,
DatabaseManager manager)
Constructor to create a connector instance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkSequenceExists(java.lang.String schema,
java.lang.String table)
Checks whether a sequence for the given target table does exist.
|
int |
connect(java.lang.String jdbcurl)
Connects to the configured database.
|
static java.util.Properties |
createParams(java.lang.String host,
int port,
java.lang.String dbname,
java.lang.String username,
java.lang.String password)
Convenience method to preconfigure a connection.
|
boolean |
createSequence(java.lang.String schema,
java.lang.String table,
int initval)
Creates a new sequence for the given target table.
|
javax.swing.tree.TreeNode[] |
createSubTree(java.lang.String[] jdbcurls)
Creates a connector specific sub-tree from a set of JDBC URLs handled by the connector.
|
java.io.InputStream |
getBytes(int columnIndex,
java.sql.ResultSet rs)
Provides the binary value from the certain column.
|
byte[] |
getBytes(java.sql.ResultSet rs,
int columnIndex)
Provides the binary value from the certain column.
|
byte[] |
getBytes(java.sql.ResultSet rs,
java.lang.String columnLabel)
Provides the binary value from the certain column.
|
java.io.InputStream |
getBytes(java.lang.String columnLabel,
java.sql.ResultSet rs)
Provides the binary value from the certain column.
|
static DatabaseConnectorDef |
getConnectorDef(boolean supported,
boolean createconnections)
Provides the connector definition to be listed without installing any connectors.
|
java.lang.String |
getDefaultConnectionURL()
Provides the JDBC URL for the default conenction (normally a user connection).
|
java.lang.String |
getDisplayURL(java.lang.String jdbcurl)
Makes sure that the given JDBC URL does not contain any passwords.
|
javax.swing.ImageIcon |
getIcon()
Provides the connector specific icon to represent it by GUI components.
|
java.sql.Connection |
getNewConnectionNoCheck(java.lang.String jdbcurl)
Creates a fresh connection for the given JDBC URL (never taken from the pool).
|
int |
getSequenceCurrentValue(java.lang.String schema,
java.lang.String table)
Reads the current (last generated) value from a sequence.
|
int |
getSequenceNextValue(java.lang.String schema,
java.lang.String table)
Reads the next value from a sequence.
|
java.lang.String |
getUserConnectionURL()
Creates a JDBC connection URL to access the database with user permissions.
|
java.lang.String |
getUserName()
Provides the name of the default user.
|
java.lang.String |
getUserPassword()
Provides the password for the default user.
|
static boolean |
isAvailableStatic()
Is the JDBC driver available on the classpath?
|
boolean |
isBinary(int metadatatype)
Checks if the given JDBC type is binary to serialize native database types properly.
|
boolean |
isConnected()
Provides the info if this connector is currently connected to the database.
|
java.lang.Class |
mapToJavaType(int metadatatype)
Provides the appropriate Java type to serialize native database types.
|
boolean |
resetSequence(java.lang.String schema,
java.lang.String table,
int nextval)
Resets an existing sequence for the given target table.
|
void |
updateBytes(java.sql.ResultSet rs,
int columnIndex,
byte[] x)
Updates the designated column with a binary value.
|
void |
updateBytes(java.sql.ResultSet rs,
int columnIndex,
java.io.InputStream inputStream)
Updates the designated column with a binary value.
|
void |
updateBytes(java.sql.ResultSet rs,
java.lang.String columnLabel,
byte[] x)
Updates the designated column with a binary value.
|
void |
updateBytes(java.sql.ResultSet rs,
java.lang.String columnLabel,
java.io.InputStream inputStream)
Updates the designated column with a binary value.
|
addSchemaMapping, checkAndCreateSchemas, disconnect, finalize, getConnectionPool, getDatabaseDescription, getDatabaseManager, getDatabaseName, getDatabaseProductName, getDatabaseProductVersion, getDefaultConnection, getDefaultSchema, getDriver, getDriverDisplayName, getDriverName, getNewConnection, getParamDatabaseHost, getParamDatabaseName, getParamDatabasePort, getParams, getPooledConnection, getSchema, getSchemaMappings, getSchemaSeparator, getSerializedField, getTableFQN, getTypeTable, getUsedSchema, isAvailable, isEmbedded, releasePooledConnection, replaceParams, replaceTableFQN, setParams, updateSchemaTables, updateSerializedField
public static final java.lang.String DATABASE_NAME
public static final java.lang.String DATABASE_DESCRIPTION
public static final java.lang.String DRIVER_NAME
public static final java.lang.String DRIVER_DISPLAY_NAME
public static final java.net.URL ICON_POSTGRESQL
public PostgreSQLConnector() throws java.lang.InstantiationException
I18NExtractor
).
java.lang.InstantiationException
- Error indicationpublic PostgreSQLConnector(java.util.Properties params, DatabaseManager manager)
params
- The database configurationmanager
- The database managerpublic java.lang.String getDisplayURL(java.lang.String jdbcurl)
getDisplayURL
in class DatabaseConnector
jdbcurl
- The original URL including passwordsjava.lang.NullPointerException
- If parameters are invalidpublic javax.swing.tree.TreeNode[] createSubTree(java.lang.String[] jdbcurls)
createSubTree
in class DatabaseConnector
jdbcurls
- The JDBC URLs to be processedjava.lang.NullPointerException
- If parameters are invalidpublic java.lang.String getUserConnectionURL()
public java.sql.Connection getNewConnectionNoCheck(java.lang.String jdbcurl) throws java.sql.SQLException
jdbcurl
- The desired connector class in FQNnull
if an error occursjava.sql.SQLException
- If something goes wrongpublic int connect(java.lang.String jdbcurl)
connect
in class DatabaseConnector
jdbcurl
- The URL for the default connectionpublic boolean isConnected()
false
then none of the connection types should be used any more.
isConnected
in class DatabaseConnector
public java.lang.String getDefaultConnectionURL()
getDefaultConnectionURL
in class DatabaseConnector
null
if an error occurspublic java.lang.String getUserName()
getUserName
in class DatabaseConnector
null
public java.lang.String getUserPassword()
getUserPassword
in class DatabaseConnector
null
public boolean checkSequenceExists(java.lang.String schema, java.lang.String table)
checkSequenceExists
in class DatabaseConnector
schema
- The target schema (optional)table
- The name of the target tablepublic boolean createSequence(java.lang.String schema, java.lang.String table, int initval)
createSequence
in class DatabaseConnector
schema
- The target schema (optional)table
- The name of the target tableinitval
- The initial value from sequencepublic int getSequenceCurrentValue(java.lang.String schema, java.lang.String table)
getSequenceCurrentValue
in class DatabaseConnector
schema
- The target schema (optional)table
- The name of the target tablepublic int getSequenceNextValue(java.lang.String schema, java.lang.String table)
getSequenceNextValue
in class DatabaseConnector
schema
- The target schema (optional)table
- The name of the target tablepublic boolean resetSequence(java.lang.String schema, java.lang.String table, int nextval)
resetSequence
in class DatabaseConnector
schema
- The target schema (optional)table
- The name of the target tablenextval
- The next value from sequencepublic javax.swing.ImageIcon getIcon()
GUIUtils.getIconVariant()
method.
getIcon
in class DatabaseConnector
public void updateBytes(java.sql.ResultSet rs, java.lang.String columnLabel, byte[] x) throws java.sql.SQLException
updateBytes
in class DatabaseConnector
rs
- The result set to be updatedcolumnLabel
- The label for the column specified with the SQL AS clausex
- The new column valuejava.lang.NullPointerException
- If a parameter is null
java.sql.SQLException
- If an SQL error occurspublic void updateBytes(java.sql.ResultSet rs, int columnIndex, byte[] x) throws java.sql.SQLException
updateBytes
in class DatabaseConnector
rs
- The result set to be updatedcolumnIndex
- The index of the column specified with the SQL AS clause (1-based)x
- The new column valuejava.lang.NullPointerException
- If a parameter is null
java.sql.SQLException
- If an SQL error occurspublic void updateBytes(java.sql.ResultSet rs, java.lang.String columnLabel, java.io.InputStream inputStream) throws java.sql.SQLException
updateBytes
in class DatabaseConnector
rs
- The result set to be updatedcolumnLabel
- The label for the column specified with the SQL AS clauseinputStream
- The new column valuejava.lang.NullPointerException
- If a parameter is null
java.sql.SQLException
- If an SQL error occurspublic void updateBytes(java.sql.ResultSet rs, int columnIndex, java.io.InputStream inputStream) throws java.sql.SQLException
updateBytes
in class DatabaseConnector
rs
- The result set to be updatedcolumnIndex
- The index of the column specified with the SQL AS clause (1-based)inputStream
- The new column valuejava.lang.NullPointerException
- If a parameter is null
java.sql.SQLException
- If an SQL error occurspublic byte[] getBytes(java.sql.ResultSet rs, java.lang.String columnLabel) throws java.sql.SQLException
getBytes
in class DatabaseConnector
rs
- The result set to be updatedcolumnLabel
- The label for the column specified with the SQL AS clausenull
indicates errorjava.lang.NullPointerException
- If a parameter is null
java.sql.SQLException
- If an SQL error occurspublic byte[] getBytes(java.sql.ResultSet rs, int columnIndex) throws java.sql.SQLException
getBytes
in class DatabaseConnector
rs
- The result set to be updatedcolumnIndex
- The index of the column specified with the SQL AS clause (1-based)null
indicates errorjava.lang.NullPointerException
- If a parameter is null
java.sql.SQLException
- If an SQL error occurspublic java.io.InputStream getBytes(java.lang.String columnLabel, java.sql.ResultSet rs) throws java.sql.SQLException
getBytes
in class DatabaseConnector
columnLabel
- The label for the column specified with the SQL AS clausers
- The result set to be updatednull
indicates errorjava.lang.NullPointerException
- If a parameter is null
java.sql.SQLException
- If an SQL error occurspublic java.io.InputStream getBytes(int columnIndex, java.sql.ResultSet rs) throws java.sql.SQLException
getBytes
in class DatabaseConnector
columnIndex
- The index of the column specified with the SQL AS clause (1-based)rs
- The result set to be updatednull
indicates errorjava.lang.NullPointerException
- If a parameter is null
java.sql.SQLException
- If an SQL error occurspublic java.lang.Class mapToJavaType(int metadatatype)
JDBCConfiguration
class may be used here.
mapToJavaType
in class DatabaseConnector
metadatatype
- The original JDBC type to be mappednull
if not supportedpublic boolean isBinary(int metadatatype)
isBinary
in class DatabaseConnector
metadatatype
- The original JDBC type to be mappedpublic static DatabaseConnectorDef getConnectorDef(boolean supported, boolean createconnections)
supported
- May the connector be used?createconnections
- May new connections be created?public static boolean isAvailableStatic()
public static java.util.Properties createParams(java.lang.String host, int port, java.lang.String dbname, java.lang.String username, java.lang.String password)
host
- The hostport
- The portdbname
- The database nameusername
- The userpassword
- The passwordCopyright © 2005-2013 Leisenfels UG (haftungsbeschränkt). All rights reserved.