com.googlecode.jdbw.server
Class AbstractDatabaseServer

java.lang.Object
  extended by com.googlecode.jdbw.server.AbstractDatabaseServer
All Implemented Interfaces:
DatabaseServer
Direct Known Subclasses:
H2FileBasedServer, H2InMemoryServer, StandardDatabaseServer

public abstract class AbstractDatabaseServer
extends Object
implements DatabaseServer

A common base class for many types of DatabaseServers. This class provides some helper methods and some default implementations for the interface methods.

If you want to create a custom DatabaseServer implementation, you probably want to extend StandardDatabaseServer instead of this class, as it has helper methods for network parameters and authentication.

Author:
Martin Berglund
See Also:
StandardDatabaseServer

Constructor Summary
AbstractDatabaseServer(JDBCDriverDescriptor driverDescriptor)
           
 
Method Summary
 DatabaseConnection connect(DataSourceFactory dataSourceFactory)
          Created a new DataSource to this server and returns it wrapped in a DatabaseConnection
protected  Properties getConnectionProperties()
           
protected  JDBCDriverDescriptor getDriverDescriptor()
           
protected abstract  String getJDBCUrl()
           
 void setConnectionProperty(String key, String value)
          Sets a property to be passed in when creating a database connection.
 void testConnection()
          Tries to create a new database connection and immediately close it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.googlecode.jdbw.DatabaseServer
getServerType
 

Constructor Detail

AbstractDatabaseServer

public AbstractDatabaseServer(JDBCDriverDescriptor driverDescriptor)
Method Detail

getConnectionProperties

protected Properties getConnectionProperties()

setConnectionProperty

public void setConnectionProperty(String key,
                                  String value)
Description copied from interface: DatabaseServer
Sets a property to be passed in when creating a database connection. These user-set properties are added to the connection properties list at the end, overriding any properties that may already have been created by the DatabaseServer implementation.

Specified by:
setConnectionProperty in interface DatabaseServer
Parameters:
key - Name of the JDBC connection property
value - Value for the JDBC connection property

connect

public DatabaseConnection connect(DataSourceFactory dataSourceFactory)
Description copied from interface: DatabaseServer
Created a new DataSource to this server and returns it wrapped in a DatabaseConnection

Specified by:
connect in interface DatabaseServer
Parameters:
dataSourceFactory - Factory to use when creating the DataSource
Returns:
DatabaseConnection connected to the server

testConnection

public void testConnection()
                    throws SQLException
Description copied from interface: DatabaseServer
Tries to create a new database connection and immediately close it. If there is any connection errors when trying to create the connection, the method will throw the corresponding SQLException that was thrown by the JDBC driver.

Specified by:
testConnection in interface DatabaseServer
Throws:
SQLException - In case there was an error connecting to the database server

getJDBCUrl

protected abstract String getJDBCUrl()

getDriverDescriptor

protected JDBCDriverDescriptor getDriverDescriptor()


Copyright © 2012. All Rights Reserved.