Package nl.cwi.monetdb.jdbc
Class MonetDataSource
java.lang.Object
nl.cwi.monetdb.jdbc.MonetWrapper
nl.cwi.monetdb.jdbc.MonetDataSource
- All Implemented Interfaces:
Wrapper,CommonDataSource,DataSource
public class MonetDataSource extends MonetWrapper implements DataSource
A DataSource suitable for the MonetDB database.
This DataSource allows retrieval of a Connection using the JNDI bean like
framework. A DataSource has numerous advantages over using the DriverManager
to retrieve a Connection object. Using the DataSource interface enables a
more transparent application where the location or database can be changed
without changing any application code.
Additionally, pooled connections can be used when using a DataSource.
- Version:
- 0.1
- Author:
- Fabian Groffen, Pedro Ferreira
-
Constructor Summary
Constructors Constructor Description MonetDataSource() -
Method Summary
Modifier and Type Method Description ConnectiongetConnection()Attempts to establish a connection with the data source that this DataSource object represents.ConnectiongetConnection(String username, String password)Attempts to establish a connection with the data source that this DataSource object represents.StringgetDescription()Gets the descriptionStringgetDirectory()Gets the directory valueintgetLoginTimeout()Gets the maximum time in seconds that this data source can wait while attempting to connect to a database.PrintWritergetLogWriter()Retrieves the log writer for this DataSource object.LoggergetParentLogger()Return the parent Logger of all the Loggers used by this data source.StringgetURL()Gets the connection URLStringgetUser()Gets the usernamebooleanisEmbedded()Gets the embedded connection directory.voidsetDescription(String description)Sets the descriptionvoidsetDirectory(String directory)Sets the directory value, meaning it wil start an embedded connectionvoidsetLoginTimeout(int seconds)Sets the maximum time in seconds that this data source will wait while attempting to connect to a database.voidsetLogWriter(PrintWriter out)Sets the log writer for this DataSource object to the given java.io.PrintWriter object.voidsetPassword(String password)Sets the password to use when connecting.voidsetURL(String url)Sets the connection URLvoidsetUser(String user)Sets the username
-
Constructor Details
-
MonetDataSource
public MonetDataSource()
-
-
Method Details
-
getConnection
Attempts to establish a connection with the data source that this DataSource object represents.- Specified by:
getConnectionin interfaceDataSource- Returns:
- a MonetConnection
- Throws:
SQLException- if connecting to the database fails
-
getConnection
Attempts to establish a connection with the data source that this DataSource object represents.- Specified by:
getConnectionin interfaceDataSource- Parameters:
username- the username to usepassword- the password to use- Returns:
- a MonetConnection
- Throws:
SQLException- if connecting to the database fails
-
getLoginTimeout
public int getLoginTimeout()Gets the maximum time in seconds that this data source can wait while attempting to connect to a database.- Specified by:
getLoginTimeoutin interfaceCommonDataSource- Specified by:
getLoginTimeoutin interfaceDataSource- Returns:
- login timeout default is 0 (infinite)
-
setLoginTimeout
public void setLoginTimeout(int seconds)Sets the maximum time in seconds that this data source will wait while attempting to connect to a database.- Specified by:
setLoginTimeoutin interfaceCommonDataSource- Specified by:
setLoginTimeoutin interfaceDataSource- Parameters:
seconds- the number of seconds to wait before aborting the connect
-
getLogWriter
Retrieves the log writer for this DataSource object.- Specified by:
getLogWriterin interfaceCommonDataSource- Specified by:
getLogWriterin interfaceDataSource- Returns:
- null, since there is no log writer
-
setLogWriter
Sets the log writer for this DataSource object to the given java.io.PrintWriter object.- Specified by:
setLogWriterin interfaceCommonDataSource- Specified by:
setLogWriterin interfaceDataSource- Parameters:
out- a PrintWriter - ignored
-
setPassword
Sets the password to use when connecting. There is no getter for obvious reasons.- Parameters:
password- the password
-
getUser
Gets the username- Returns:
- the username
-
setUser
Sets the username- Parameters:
user- the username
-
getURL
Gets the connection URL- Returns:
- the connection URL
-
setURL
Sets the connection URL- Parameters:
url- the connection URL
-
getDescription
Gets the description- Returns:
- the description
-
setDescription
Sets the description- Parameters:
description- the description
-
getDirectory
Gets the directory value- Returns:
- the directory value
-
setDirectory
Sets the directory value, meaning it wil start an embedded connection- Parameters:
directory- The directory location
-
isEmbedded
public boolean isEmbedded()Gets the embedded connection directory. If not, then a MAPI connection will be created instead.- Returns:
- If the connection will be embedded. If not, then a MAPI connection will be created instead.
-
getParentLogger
Return the parent Logger of all the Loggers used by this data source. This should be the Logger farthest from the root Logger that is still an ancestor of all of the Loggers used by this data source. Configuring this Logger will affect all of the log messages generated by the data source. In the worst case, this may be the root Logger.- Specified by:
getParentLoggerin interfaceCommonDataSource- Returns:
- the parent Logger for this data source
- Throws:
SQLFeatureNotSupportedException- if the data source does not use java.util.logging
-