de.topicmapslab.majortom.database.jdbc.postgres.base
Class BasePostGreSqlConnectionProvider

java.lang.Object
  extended by de.topicmapslab.majortom.database.jdbc.rdbms.RDBMSConnectionProvider
      extended by de.topicmapslab.majortom.database.jdbc.postgres.base.BasePostGreSqlConnectionProvider
All Implemented Interfaces:
IConnectionProvider
Direct Known Subclasses:
Sql99ConnectionProvider

public abstract class BasePostGreSqlConnectionProvider
extends RDBMSConnectionProvider

Special connection provider for PostGreSQL.

Author:
Sven Krosse

Field Summary
private static java.lang.String ORG_POSTGRESQL_DRIVER
          constant for driver class
private  org.postgresql.ds.PGConnectionPoolDataSource pool
           
private static java.lang.String POSTGRESQL
          constant for database name
protected static java.util.Map<java.lang.String,java.util.List<java.lang.String>> schemaInformation
           
 
Fields inherited from interface de.topicmapslab.majortom.database.jdbc.model.IConnectionProvider
DATABASE_NOT_EXISTS, STATE_DATABASE_IS_EMPTY, STATE_DATABASE_IS_INVALID, STATE_DATABASE_IS_VALID
 
Constructor Summary
protected BasePostGreSqlConnectionProvider()
          constructor
  BasePostGreSqlConnectionProvider(java.lang.String host, java.lang.String database, java.lang.String user, java.lang.String password)
          Constructor
 
Method Summary
 java.sql.Connection getConnection()
          Opens a connection by using the connection pool
 int getDatabaseState()
          Method checks if the schema of the current database connection is valid..
 java.lang.String getDriverClassName()
          Returning the name of the used driver class
 java.lang.String getRdbmsName()
          Returning the name of the used RDBMS
private  void initializeConnectionPool()
          Method is called to initialize the connection pool
 void setTopicMapStore(JdbcTopicMapStore store)
          Method set the internal reference of the JDBC topic map store to the given reference.
 
Methods inherited from class de.topicmapslab.majortom.database.jdbc.rdbms.RDBMSConnectionProvider
close, createSchema, getConnectionCount, getDatabase, getDatabaseMetaData, getGlobalSession, getHost, getPassword, getSchemaQueries, getSchemaQuery, getTopicMapStore, getUrl, getUser, openSession
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POSTGRESQL

private static final java.lang.String POSTGRESQL
constant for database name

See Also:
Constant Field Values

ORG_POSTGRESQL_DRIVER

private static final java.lang.String ORG_POSTGRESQL_DRIVER
constant for driver class

See Also:
Constant Field Values

schemaInformation

protected static final java.util.Map<java.lang.String,java.util.List<java.lang.String>> schemaInformation

pool

private org.postgresql.ds.PGConnectionPoolDataSource pool
Constructor Detail

BasePostGreSqlConnectionProvider

protected BasePostGreSqlConnectionProvider()
constructor


BasePostGreSqlConnectionProvider

public BasePostGreSqlConnectionProvider(java.lang.String host,
                                        java.lang.String database,
                                        java.lang.String user,
                                        java.lang.String password)
Constructor

Parameters:
host - the host
database - database
user - the user
password - the password
Method Detail

initializeConnectionPool

private final void initializeConnectionPool()
Method is called to initialize the connection pool


setTopicMapStore

public void setTopicMapStore(JdbcTopicMapStore store)
Method set the internal reference of the JDBC topic map store to the given reference.

Specified by:
setTopicMapStore in interface IConnectionProvider
Overrides:
setTopicMapStore in class RDBMSConnectionProvider
Parameters:
store - the topic map store

getDatabaseState

public int getDatabaseState()
                     throws java.sql.SQLException
Method checks if the schema of the current database connection is valid..

Specified by:
getDatabaseState in interface IConnectionProvider
Overrides:
getDatabaseState in class RDBMSConnectionProvider
Returns:

0 if the database is empty.
1 if the database schema is invalid.
2 if the database schema is valid.

Throws:
java.sql.SQLException

getDriverClassName

public java.lang.String getDriverClassName()
Returning the name of the used driver class

Returns:
the name of the used driver class

getRdbmsName

public java.lang.String getRdbmsName()
Returning the name of the used RDBMS

Returns:
the name of the RDBMS

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Opens a connection by using the connection pool

Returns:
the connection from connection pool
Throws:
java.sql.SQLException