Package mgui.datasources
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 attributename
, ornull
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 aDataSourceDialogPanel
to specify this data source.java.lang.String
getDataSourceFromUrl(java.lang.String url)
Extracts a data source name from a driver-specific URLFileLoader
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)
Convertsstring
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 availablejava.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 fromname
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 markboolean
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 availableboolean
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 theInterfaceIOType
associated with this persistent object's loader.boolean
setFileWriter(InterfaceIOType io_type)
Sets theInterfaceIOType
associated with this persistent object's writer.void
setLoaderOptions(InterfaceIOOptions options)
Sets the options used to last load this object; can benull
.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 benull
.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
-
writer
-
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
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 interfacePersistentObject
- Returns:
-
getFileLoader
Description copied from interface:PersistentObject
Returns an instance of the file loader associated with this persistent object.- Specified by:
getFileLoader
in interfacePersistentObject
- Returns:
-
setFileLoader
Description copied from interface:PersistentObject
Sets theInterfaceIOType
associated with this persistent object's loader.- Specified by:
setFileLoader
in interfacePersistentObject
- Returns:
-
getFileWriter
Description copied from interface:PersistentObject
Returns an instance of the file writer associated with this persistent object.- Specified by:
getFileWriter
in interfacePersistentObject
- Returns:
-
setFileWriter
Description copied from interface:PersistentObject
Sets theInterfaceIOType
associated with this persistent object's writer.- Specified by:
setFileWriter
in interfacePersistentObject
- 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 interfacePersistentObject
-
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 interfaceNamedObject
- Returns:
-
setName
public void setName(java.lang.String name)Description copied from interface:NamedObject
Sets the name for this object.- Specified by:
setName
in interfaceNamedObject
-
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 notnull
, fills this map with database properties- Returns:
-
getSQLName
public java.lang.String getSQLName(java.lang.String name)Returns a string fromname
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; seeTypes
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)Convertsstring
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 classjava.lang.Object
-
getDataSourceDialogPanel
Returns aDataSourceDialogPanel
to specify this data source.- Returns:
-
getAttributes
Description copied from interface:AttributeObject
Returns the list of current attributes for this object.- Specified by:
getAttributes
in interfaceAttributeObject
- Returns:
-
getAttribute
Description copied from interface:AttributeObject
Returns a specific attribute for this object.- Specified by:
getAttribute
in interfaceAttributeObject
- Returns:
-
getAttributeValue
public java.lang.Object getAttributeValue(java.lang.String name)Description copied from interface:AttributeObject
Gets the value of attributename
, ornull
if it does not exist.- Specified by:
getAttributeValue
in interfaceAttributeObject
- Parameters:
name
- Name of the attribute- Returns:
- the value of attribute
name
, ornull
if it does not exist
-
setAttributes
Description copied from interface:AttributeObject
Sets the list of attributes for this object.- Specified by:
setAttributes
in interfaceAttributeObject
-
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 interfaceAttributeObject
-
getLoaderOptions
Description copied from interface:PersistentObject
Returns the options used to last load this object, if available- Specified by:
getLoaderOptions
in interfacePersistentObject
- Returns:
- The options, or
null
if none exist
-
setLoaderOptions
Description copied from interface:PersistentObject
Sets the options used to last load this object; can benull
.- Specified by:
setLoaderOptions
in interfacePersistentObject
-
getWriterOptions
Description copied from interface:PersistentObject
Returns the options used to last write this object, if available- Specified by:
getWriterOptions
in interfacePersistentObject
- Returns:
- The options, or
null
if none exist
-
setWriterOptions
Description copied from interface:PersistentObject
Sets the options used to last write this object; can benull
.- Specified by:
setWriterOptions
in interfacePersistentObject
-