Class DataSourceDriver

java.lang.Object
mgui.datasources.DataSourceDriver
All Implemented Interfaces:
java.lang.Cloneable, AttributeObject, PersistentObject, NamedObject
Direct Known Subclasses:
JdbcOdbcDriver, MySQLDriver, PostgreSQLDriver, TinySQLDriver

public class DataSourceDriver
extends java.lang.Object
implements PersistentObject, java.lang.Cloneable, AttributeObject
Defines a JDBC driver for a DataConnection.
Since:
1.0
Version:
1.0
Author:
Andrew Reid
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected AttributeList attributes  
    protected java.lang.String className  
    protected java.net.URL file_ref  
    protected FileLoader loader  
    protected java.lang.String login  
    protected java.lang.String name  
    protected java.lang.String password  
    protected boolean ssl  
    protected java.lang.String url  
    protected FileWriter writer  
  • Constructor Summary

    Constructors
    Constructor Description
    DataSourceDriver()  
    DataSourceDriver​(java.lang.String name, java.lang.String class_name, java.lang.String url)  
    DataSourceDriver​(java.lang.String name, java.lang.String class_name, java.lang.String url, java.lang.String user, java.lang.String password)  
    DataSourceDriver​(java.lang.String name, java.lang.String class_name, java.lang.String url, java.lang.String user, java.lang.String password, boolean ssl)  
  • Method Summary

    Modifier and Type Method Description
    java.lang.Object clone()  
    void dropDatabase​(DataSource source)
    Instructs the database server to drop the specified data source.
    Attribute<?> getAttribute​(java.lang.String attrName)
    Returns a specific attribute for this object.
    AttributeList getAttributes()
    Returns the list of current attributes for this object.
    java.lang.Object getAttributeValue​(java.lang.String name)
    Gets the value of attribute name, or null if it does not exist.
    java.lang.String getClassName()  
    java.sql.Connection getConnection()  
    java.lang.String getCreateDatabaseSQL​(java.lang.String name)
    Generates a driver-specific SQL string for creating a new database.
    java.util.ArrayList<java.lang.String> getDatabases()
    If implemented, returns a list of properties the databases currently accessible through this driver.
    java.util.ArrayList<java.lang.String> getDatabases​(java.util.HashMap<java.lang.String,​java.util.HashMap<java.lang.String,​java.lang.String>> properties)
    If implemented, returns a map of properties the databases currently accessible through this driver.
    DataSourceDialogPanel getDataSourceDialogPanel()
    Returns a DataSourceDialogPanel to specify this data source.
    java.lang.String getDataSourceFromUrl​(java.lang.String url)
    Extracts a data source name from a driver-specific URL
    FileLoader getFileLoader()
    Returns an instance of the file loader associated with this persistent object.
    FileWriter getFileWriter()
    Returns an instance of the file writer associated with this persistent object.
    java.lang.String getFriendlyName​(java.lang.String string)
    Converts string to a "friendly" string; i.e., replacing all illegal characters with acceptable ones.
    InterfaceIOOptions getLoaderOptions()
    Returns the options used to last load this object, if available
    java.lang.String getLogin()  
    java.lang.String getName()
    Gets the name for this object.
    java.lang.String getPassword()  
    java.lang.String getSQLName​(java.lang.String name)
    Returns a string from name that is safe for this driver.
    java.lang.String getSQLQuote()
    Returns a driver-specific SQL quotation mark; subclasses should only override this if their drivers expect non-standard SQL input.
    java.lang.String getSQLType​(int sql_type, int length)
    Returns a driver-specific SQL quotation mark
    boolean getSSL()  
    java.lang.String getUrl()  
    java.lang.String getUrlFromName​(java.lang.String name)  
    java.lang.String getUrlPrefix()  
    java.net.URL getUrlReference()
    Returns the URL reference for this persistent object; i.e., the location where its data were loaded and where it should be written.
    InterfaceIOOptions getWriterOptions()
    Returns the options used to last write this object, if available
    boolean init()  
    void setAttribute​(java.lang.String attrName, java.lang.Object newValue)
    Sets a value for a specific attribute.
    void setAttributes​(AttributeList thisList)
    Sets the list of attributes for this object.
    void setClassName​(java.lang.String s)  
    boolean setFileLoader​(InterfaceIOType io_type)
    Sets the InterfaceIOType associated with this persistent object's loader.
    boolean setFileWriter​(InterfaceIOType io_type)
    Sets the InterfaceIOType associated with this persistent object's writer.
    void setLoaderOptions​(InterfaceIOOptions options)
    Sets the options used to last load this object; can be null.
    void setLogin​(java.lang.String login)  
    void setName​(java.lang.String name)
    Sets the name for this object.
    void setPassword​(java.lang.String password)  
    void setUrl​(java.lang.String url)  
    void setUrlReference​(java.net.URL url)
    Sets the URL reference for this persistent object; i.e., the location where its data were loaded and where it should be written.
    void setWriterOptions​(InterfaceIOOptions options)
    Sets the options used to last write this object; can be null.

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • name

      protected java.lang.String name
    • className

      protected java.lang.String className
    • login

      protected java.lang.String login
    • password

      protected java.lang.String password
    • url

      protected java.lang.String url
    • ssl

      protected boolean ssl
    • file_ref

      protected java.net.URL file_ref
    • loader

      protected FileLoader loader
    • writer

      protected FileWriter writer
    • attributes

      protected AttributeList attributes
  • Constructor Details

    • DataSourceDriver

      public DataSourceDriver()
    • DataSourceDriver

      public DataSourceDriver​(java.lang.String name, java.lang.String class_name, java.lang.String url)
    • DataSourceDriver

      public DataSourceDriver​(java.lang.String name, java.lang.String class_name, java.lang.String url, java.lang.String user, java.lang.String password)
    • DataSourceDriver

      public DataSourceDriver​(java.lang.String name, java.lang.String class_name, java.lang.String url, java.lang.String user, java.lang.String password, boolean ssl)
  • Method Details

    • init

      public boolean init()
    • dropDatabase

      public void dropDatabase​(DataSource source) throws DataSourceException
      Instructs the database server to drop the specified data source. If the data source is open, it will be closed; if this fails an Exception is thrown.
      Parameters:
      name -
      Throws:
      DataSourceException
    • getCreateDatabaseSQL

      public java.lang.String getCreateDatabaseSQL​(java.lang.String name)
      Generates a driver-specific SQL string for creating a new database.
      Parameters:
      name - Name for the new database
      Returns:
    • getUrlReference

      public java.net.URL getUrlReference()
      Description copied from interface: PersistentObject
      Returns the URL reference for this persistent object; i.e., the location where its data were loaded and where it should be written.
      Specified by:
      getUrlReference in interface PersistentObject
      Returns:
    • getFileLoader

      public FileLoader getFileLoader()
      Description copied from interface: PersistentObject
      Returns an instance of the file loader associated with this persistent object.
      Specified by:
      getFileLoader in interface PersistentObject
      Returns:
    • setFileLoader

      public boolean setFileLoader​(InterfaceIOType io_type)
      Description copied from interface: PersistentObject
      Sets the InterfaceIOType associated with this persistent object's loader.
      Specified by:
      setFileLoader in interface PersistentObject
      Returns:
    • getFileWriter

      public FileWriter getFileWriter()
      Description copied from interface: PersistentObject
      Returns an instance of the file writer associated with this persistent object.
      Specified by:
      getFileWriter in interface PersistentObject
      Returns:
    • setFileWriter

      public boolean setFileWriter​(InterfaceIOType io_type)
      Description copied from interface: PersistentObject
      Sets the InterfaceIOType associated with this persistent object's writer.
      Specified by:
      setFileWriter in interface PersistentObject
      Returns:
    • setUrlReference

      public void setUrlReference​(java.net.URL url)
      Description copied from interface: PersistentObject
      Sets the URL reference for this persistent object; i.e., the location where its data were loaded and where it should be written.
      Specified by:
      setUrlReference in interface PersistentObject
    • setClassName

      public void setClassName​(java.lang.String s)
    • getClassName

      public java.lang.String getClassName()
    • getSSL

      public boolean getSSL()
    • getName

      public java.lang.String getName()
      Description copied from interface: NamedObject
      Gets the name for this object.
      Specified by:
      getName in interface NamedObject
      Returns:
    • setName

      public void setName​(java.lang.String name)
      Description copied from interface: NamedObject
      Sets the name for this object.
      Specified by:
      setName in interface NamedObject
    • getLogin

      public java.lang.String getLogin()
    • setLogin

      public void setLogin​(java.lang.String login)
    • getPassword

      public java.lang.String getPassword()
    • setPassword

      public void setPassword​(java.lang.String password)
    • getUrl

      public java.lang.String getUrl()
    • setUrl

      public void setUrl​(java.lang.String url)
    • getDataSourceFromUrl

      public java.lang.String getDataSourceFromUrl​(java.lang.String url)
      Extracts a data source name from a driver-specific URL
      Parameters:
      url -
      Returns:
    • getUrlFromName

      public java.lang.String getUrlFromName​(java.lang.String name)
    • getUrlPrefix

      public java.lang.String getUrlPrefix()
    • getDatabases

      public java.util.ArrayList<java.lang.String> getDatabases()
      If implemented, returns a list of properties the databases currently accessible through this driver. Otherwise, returns an empty list.
      Returns:
    • getDatabases

      public java.util.ArrayList<java.lang.String> getDatabases​(java.util.HashMap<java.lang.String,​java.util.HashMap<java.lang.String,​java.lang.String>> properties)
      If implemented, returns a map of properties the databases currently accessible through this driver. Otherwise, returns an empty map.
      Parameters:
      properties - If not null, fills this map with database properties
      Returns:
    • getSQLName

      public java.lang.String getSQLName​(java.lang.String name)
      Returns a string from name that is safe for this driver.
      Parameters:
      name -
      Returns:
    • getSQLQuote

      public java.lang.String getSQLQuote()
      Returns a driver-specific SQL quotation mark; subclasses should only override this if their drivers expect non-standard SQL input.
      Returns:
    • getSQLType

      public java.lang.String getSQLType​(int sql_type, int length)
      Returns a driver-specific SQL quotation mark
      Parameters:
      sql_type - An SQL type; see Types
      length - The length of the field; for variable-length fields only
      Returns:
    • getConnection

      public java.sql.Connection getConnection() throws mgui.interfaces.security.StringEncrypter.EncryptionException, java.sql.SQLException
      Throws:
      mgui.interfaces.security.StringEncrypter.EncryptionException
      java.sql.SQLException
    • getFriendlyName

      public java.lang.String getFriendlyName​(java.lang.String string)
      Converts string to a "friendly" string; i.e., replacing all illegal characters with acceptable ones.
      Parameters:
      string -
      Returns:
    • clone

      public java.lang.Object clone()
      Overrides:
      clone in class java.lang.Object
    • getDataSourceDialogPanel

      public DataSourceDialogPanel getDataSourceDialogPanel()
      Returns a DataSourceDialogPanel to specify this data source.
      Returns:
    • getAttributes

      public AttributeList getAttributes()
      Description copied from interface: AttributeObject
      Returns the list of current attributes for this object.
      Specified by:
      getAttributes in interface AttributeObject
      Returns:
    • getAttribute

      public Attribute<?> getAttribute​(java.lang.String attrName)
      Description copied from interface: AttributeObject
      Returns a specific attribute for this object.
      Specified by:
      getAttribute in interface AttributeObject
      Returns:
    • getAttributeValue

      public java.lang.Object getAttributeValue​(java.lang.String name)
      Description copied from interface: AttributeObject
      Gets the value of attribute name, or null if it does not exist.
      Specified by:
      getAttributeValue in interface AttributeObject
      Parameters:
      name - Name of the attribute
      Returns:
      the value of attribute name, or null if it does not exist
    • setAttributes

      public void setAttributes​(AttributeList thisList)
      Description copied from interface: AttributeObject
      Sets the list of attributes for this object.
      Specified by:
      setAttributes in interface AttributeObject
    • setAttribute

      public void setAttribute​(java.lang.String attrName, java.lang.Object newValue)
      Description copied from interface: AttributeObject
      Sets a value for a specific attribute.
      Specified by:
      setAttribute in interface AttributeObject
    • getLoaderOptions

      public InterfaceIOOptions getLoaderOptions()
      Description copied from interface: PersistentObject
      Returns the options used to last load this object, if available
      Specified by:
      getLoaderOptions in interface PersistentObject
      Returns:
      The options, or null if none exist
    • setLoaderOptions

      public void setLoaderOptions​(InterfaceIOOptions options)
      Description copied from interface: PersistentObject
      Sets the options used to last load this object; can be null.
      Specified by:
      setLoaderOptions in interface PersistentObject
    • getWriterOptions

      public InterfaceIOOptions getWriterOptions()
      Description copied from interface: PersistentObject
      Returns the options used to last write this object, if available
      Specified by:
      getWriterOptions in interface PersistentObject
      Returns:
      The options, or null if none exist
    • setWriterOptions

      public void setWriterOptions​(InterfaceIOOptions options)
      Description copied from interface: PersistentObject
      Sets the options used to last write this object; can be null.
      Specified by:
      setWriterOptions in interface PersistentObject