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 AttributeListattributesprotected java.lang.StringclassNameprotected java.net.URLfile_refprotected FileLoaderloaderprotected java.lang.Stringloginprotected java.lang.Stringnameprotected java.lang.Stringpasswordprotected booleansslprotected java.lang.Stringurlprotected FileWriterwriter -
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.Objectclone()voiddropDatabase(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.AttributeListgetAttributes()Returns the list of current attributes for this object.java.lang.ObjectgetAttributeValue(java.lang.String name)Gets the value of attributename, ornullif it does not exist.java.lang.StringgetClassName()java.sql.ConnectiongetConnection()java.lang.StringgetCreateDatabaseSQL(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.DataSourceDialogPanelgetDataSourceDialogPanel()Returns aDataSourceDialogPanelto specify this data source.java.lang.StringgetDataSourceFromUrl(java.lang.String url)Extracts a data source name from a driver-specific URLFileLoadergetFileLoader()Returns an instance of the file loader associated with this persistent object.FileWritergetFileWriter()Returns an instance of the file writer associated with this persistent object.java.lang.StringgetFriendlyName(java.lang.String string)Convertsstringto a "friendly" string; i.e., replacing all illegal characters with acceptable ones.InterfaceIOOptionsgetLoaderOptions()Returns the options used to last load this object, if availablejava.lang.StringgetLogin()java.lang.StringgetName()Gets the name for this object.java.lang.StringgetPassword()java.lang.StringgetSQLName(java.lang.String name)Returns a string fromnamethat is safe for this driver.java.lang.StringgetSQLQuote()Returns a driver-specific SQL quotation mark; subclasses should only override this if their drivers expect non-standard SQL input.java.lang.StringgetSQLType(int sql_type, int length)Returns a driver-specific SQL quotation markbooleangetSSL()java.lang.StringgetUrl()java.lang.StringgetUrlFromName(java.lang.String name)java.lang.StringgetUrlPrefix()java.net.URLgetUrlReference()Returns the URL reference for this persistent object; i.e., the location where its data were loaded and where it should be written.InterfaceIOOptionsgetWriterOptions()Returns the options used to last write this object, if availablebooleaninit()voidsetAttribute(java.lang.String attrName, java.lang.Object newValue)Sets a value for a specific attribute.voidsetAttributes(AttributeList thisList)Sets the list of attributes for this object.voidsetClassName(java.lang.String s)booleansetFileLoader(InterfaceIOType io_type)Sets theInterfaceIOTypeassociated with this persistent object's loader.booleansetFileWriter(InterfaceIOType io_type)Sets theInterfaceIOTypeassociated with this persistent object's writer.voidsetLoaderOptions(InterfaceIOOptions options)Sets the options used to last load this object; can benull.voidsetLogin(java.lang.String login)voidsetName(java.lang.String name)Sets the name for this object.voidsetPassword(java.lang.String password)voidsetUrl(java.lang.String url)voidsetUrlReference(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.voidsetWriterOptions(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:PersistentObjectReturns the URL reference for this persistent object; i.e., the location where its data were loaded and where it should be written.- Specified by:
getUrlReferencein interfacePersistentObject- Returns:
-
getFileLoader
Description copied from interface:PersistentObjectReturns an instance of the file loader associated with this persistent object.- Specified by:
getFileLoaderin interfacePersistentObject- Returns:
-
setFileLoader
Description copied from interface:PersistentObjectSets theInterfaceIOTypeassociated with this persistent object's loader.- Specified by:
setFileLoaderin interfacePersistentObject- Returns:
-
getFileWriter
Description copied from interface:PersistentObjectReturns an instance of the file writer associated with this persistent object.- Specified by:
getFileWriterin interfacePersistentObject- Returns:
-
setFileWriter
Description copied from interface:PersistentObjectSets theInterfaceIOTypeassociated with this persistent object's writer.- Specified by:
setFileWriterin interfacePersistentObject- Returns:
-
setUrlReference
public void setUrlReference(java.net.URL url)Description copied from interface:PersistentObjectSets the URL reference for this persistent object; i.e., the location where its data were loaded and where it should be written.- Specified by:
setUrlReferencein 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:NamedObjectGets the name for this object.- Specified by:
getNamein interfaceNamedObject- Returns:
-
setName
public void setName(java.lang.String name)Description copied from interface:NamedObjectSets the name for this object.- Specified by:
setNamein 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 fromnamethat 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; seeTypeslength- 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.EncryptionExceptionjava.sql.SQLException
-
getFriendlyName
public java.lang.String getFriendlyName(java.lang.String string)Convertsstringto a "friendly" string; i.e., replacing all illegal characters with acceptable ones.- Parameters:
string-- Returns:
-
clone
public java.lang.Object clone()- Overrides:
clonein classjava.lang.Object
-
getDataSourceDialogPanel
Returns aDataSourceDialogPanelto specify this data source.- Returns:
-
getAttributes
Description copied from interface:AttributeObjectReturns the list of current attributes for this object.- Specified by:
getAttributesin interfaceAttributeObject- Returns:
-
getAttribute
Description copied from interface:AttributeObjectReturns a specific attribute for this object.- Specified by:
getAttributein interfaceAttributeObject- Returns:
-
getAttributeValue
public java.lang.Object getAttributeValue(java.lang.String name)Description copied from interface:AttributeObjectGets the value of attributename, ornullif it does not exist.- Specified by:
getAttributeValuein interfaceAttributeObject- Parameters:
name- Name of the attribute- Returns:
- the value of attribute
name, ornullif it does not exist
-
setAttributes
Description copied from interface:AttributeObjectSets the list of attributes for this object.- Specified by:
setAttributesin interfaceAttributeObject
-
setAttribute
public void setAttribute(java.lang.String attrName, java.lang.Object newValue)Description copied from interface:AttributeObjectSets a value for a specific attribute.- Specified by:
setAttributein interfaceAttributeObject
-
getLoaderOptions
Description copied from interface:PersistentObjectReturns the options used to last load this object, if available- Specified by:
getLoaderOptionsin interfacePersistentObject- Returns:
- The options, or
nullif none exist
-
setLoaderOptions
Description copied from interface:PersistentObjectSets the options used to last load this object; can benull.- Specified by:
setLoaderOptionsin interfacePersistentObject
-
getWriterOptions
Description copied from interface:PersistentObjectReturns the options used to last write this object, if available- Specified by:
getWriterOptionsin interfacePersistentObject- Returns:
- The options, or
nullif none exist
-
setWriterOptions
Description copied from interface:PersistentObjectSets the options used to last write this object; can benull.- Specified by:
setWriterOptionsin interfacePersistentObject
-