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 Details

  • Method Details

    • getConnection

      public Connection getConnection() throws SQLException
      Attempts to establish a connection with the data source that this DataSource object represents.
      Specified by:
      getConnection in interface DataSource
      Returns:
      a MonetConnection
      Throws:
      SQLException - if connecting to the database fails
    • getConnection

      public Connection getConnection​(String username, String password) throws SQLException
      Attempts to establish a connection with the data source that this DataSource object represents.
      Specified by:
      getConnection in interface DataSource
      Parameters:
      username - the username to use
      password - 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:
      getLoginTimeout in interface CommonDataSource
      Specified by:
      getLoginTimeout in interface DataSource
      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:
      setLoginTimeout in interface CommonDataSource
      Specified by:
      setLoginTimeout in interface DataSource
      Parameters:
      seconds - the number of seconds to wait before aborting the connect
    • getLogWriter

      public PrintWriter getLogWriter()
      Retrieves the log writer for this DataSource object.
      Specified by:
      getLogWriter in interface CommonDataSource
      Specified by:
      getLogWriter in interface DataSource
      Returns:
      null, since there is no log writer
    • setLogWriter

      public void setLogWriter​(PrintWriter out)
      Sets the log writer for this DataSource object to the given java.io.PrintWriter object.
      Specified by:
      setLogWriter in interface CommonDataSource
      Specified by:
      setLogWriter in interface DataSource
      Parameters:
      out - a PrintWriter - ignored
    • setPassword

      public void setPassword​(String password)
      Sets the password to use when connecting. There is no getter for obvious reasons.
      Parameters:
      password - the password
    • getUser

      public String getUser()
      Gets the username
      Returns:
      the username
    • setUser

      public void setUser​(String user)
      Sets the username
      Parameters:
      user - the username
    • getURL

      public String getURL()
      Gets the connection URL
      Returns:
      the connection URL
    • setURL

      public void setURL​(String url)
      Sets the connection URL
      Parameters:
      url - the connection URL
    • getDescription

      public String getDescription()
      Gets the description
      Returns:
      the description
    • setDescription

      public void setDescription​(String description)
      Sets the description
      Parameters:
      description - the description
    • getDirectory

      public String getDirectory()
      Gets the directory value
      Returns:
      the directory value
    • setDirectory

      public void setDirectory​(String directory)
      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

      public Logger getParentLogger() throws SQLFeatureNotSupportedException
      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:
      getParentLogger in interface CommonDataSource
      Returns:
      the parent Logger for this data source
      Throws:
      SQLFeatureNotSupportedException - if the data source does not use java.util.logging