de.hpi.fgis.dude.database.adapter
Class Database

java.lang.Object
  extended by de.hpi.fgis.dude.database.adapter.Database
All Implemented Interfaces:
AutoJsonable
Direct Known Subclasses:
DB2Database, MySQLDatabase, OracleDatabase, PostGreSQLDatabase

public abstract class Database
extends Object
implements AutoJsonable

Database is an abstract class that encapsulates the database related information. It is used to simply add new databases to the tool. A new database class has to extend Database. Additionally, the JDBC library for that database has to be added.

Author:
Matthias Pohl

Constructor Summary
Database(DBInfo dbInfo)
          Initializes the database instance members and loads the settings provided by the parameter dbInfo.
Database(InputStream iStream)
          Initializes the database using the passed InputStream.
Database(Properties prop)
          Initializes the database using the passed Properties.
 
Method Summary
 Connection createConnection()
          Returns a Connection object, which represents a new connection to the database.
 boolean equals(Database other)
          Checks whether two Database instances have the same information stored.
abstract  String getDatabaseDriverName()
          Returns the Driver's name used for loading the Driver class.
 String getDatabaseName()
          Returns the name of the database.
 String getHost()
          Returns the host information of the underlying database system.
abstract  String getJDBCString()
          Returns the JDBC String which can be used for representing a connection to this database.
 int getPort()
          Returns the port of the underlying database system.
 String getSQLSchema()
          Returns the schema, which is used by this database connection.
 void loadDatabaseInformation(InputStream iStream)
          Loads the data from the InputStream.
 void loadDatabaseInformation(Properties prop)
          Loads the data from a Properties instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Database

public Database(DBInfo dbInfo)
Initializes the database instance members and loads the settings provided by the parameter dbInfo.

Parameters:
dbInfo - Information needed for establishing a connection to this database.

Database

public Database(InputStream iStream)
Initializes the database using the passed InputStream. The information provided by this stream has to convertible into a Properties instance.

Parameters:
iStream - The InputStream that provides the connection information.

Database

public Database(Properties prop)
Initializes the database using the passed Properties.

Parameters:
prop - The Properties instance that provides the connection information.
Method Detail

loadDatabaseInformation

public void loadDatabaseInformation(InputStream iStream)
Loads the data from the InputStream.

Parameters:
iStream - The stream from which the database information are read.

loadDatabaseInformation

public void loadDatabaseInformation(Properties prop)
Loads the data from a Properties instance.

Parameters:
prop - The properties from which the database information are read.

getSQLSchema

public String getSQLSchema()
Returns the schema, which is used by this database connection.

Returns:
SQL Schema used by this connection.

getHost

public String getHost()
Returns the host information of the underlying database system.

Returns:
The host information of the underlying database system.

getPort

public int getPort()
Returns the port of the underlying database system.

Returns:
The port of the underlying database system.

getDatabaseName

public String getDatabaseName()
Returns the name of the database.

Returns:
The name of the database.

createConnection

public Connection createConnection()
                            throws SQLException,
                                   ClassNotFoundException
Returns a Connection object, which represents a new connection to the database.

Returns:
Connection object used for this database.
Throws:
SQLException - If the connection could not be established.
ClassNotFoundException - If the Driver class could not be loaded.

equals

public boolean equals(Database other)
Checks whether two Database instances have the same information stored.

Parameters:
other - The other Database instance.
Returns:
true, if all the information is the same; otherwise false.

getJDBCString

public abstract String getJDBCString()
Returns the JDBC String which can be used for representing a connection to this database.

Returns:
The JDBC String for this database connection.

getDatabaseDriverName

public abstract String getDatabaseDriverName()
Returns the Driver's name used for loading the Driver class. The corresponding library has to be added to the build path.

Returns:
The Driver class name which is used for the database connection.


Copyright © 2011 Hasso Plattner Institute - Chair of Information Systems. All Rights Reserved.