|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.core.converters.AbstractSaver
weka.core.converters.DatabaseSaver
public class DatabaseSaver
Writes to a database (tested with MySQL, InstantDB, HSQLDB).
Valid options are:-url <JDBC URL> The JDBC URL to connect to. (default: from DatabaseUtils.props file)
-user <name> The user to connect with to the database. (default: none)
-password <password> The password to connect with to the database. (default: none)
-T <table name> The name of the table. (default: the relation name)
-P Add an ID column as primary key. The name is specified in the DatabaseUtils file ('idColumn'). The DatabaseLoader won't load this column.
-i <input file name> Input file in arff format that should be saved in database.WARNING:This class was taken from the weka_src.jar and modified in order to put some logs and to make possible the connection to the DB through SpagoBI
Field Summary | |
---|---|
protected int |
dbWriteMode
reads the property file |
static int |
DELETE_INSERT
|
static int |
DROP_INSERT
|
static int |
INSERT
|
protected java.lang.String[] |
keyColumnNames
|
protected static java.util.Properties |
PROPERTIES
Properties associated with the database connection. |
protected static java.lang.String |
PROPERTY_FILE
The property file for the database connection. |
static int |
UPDATE_INSERT
|
protected java.lang.String |
version
|
protected java.lang.String |
versionColumnName
|
protected boolean |
versioning
|
Fields inherited from class weka.core.converters.AbstractSaver |
---|
CANCEL, m_retrieval, STRUCTURE_READY, WAIT, WRITE |
Fields inherited from interface weka.core.converters.Saver |
---|
BATCH, INCREMENTAL, NONE |
Constructor Summary | |
---|---|
DatabaseSaver()
Constructor. |
Method Summary | |
---|---|
java.lang.String |
autoKeyGenerationTipText()
Returns the tip text for this property. |
void |
cancel()
Cancels the incremental saving process and tries to drop the table if the write mode is CANCEL. |
void |
connectToDatabase()
Opens a connection to the database. |
boolean |
getAutoKeyGeneration()
Gets whether or not a primary key will be generated automatically. |
weka.core.Capabilities |
getCapabilities()
Returns the Capabilities of this saver. |
java.lang.String[] |
getKeyColumnNames()
Gets the key column names. |
java.lang.String[] |
getOptions()
Gets the setting. |
java.lang.String |
getPassword()
Returns the database password. |
boolean |
getRelationForTableName()
Gets whether or not the relation name is used as name of the table. |
java.lang.String |
getRevision()
Returns the revision string. |
java.lang.String |
getTableName()
Gets the table's name. |
java.lang.String |
getUrl()
Gets the database URL. |
java.lang.String |
getUser()
Gets the database user. |
java.lang.String |
getVersion()
Gets the version. |
java.lang.String |
getVersionColumnName()
Gets the version column name. |
java.lang.String |
globalInfo()
Returns a string describing this Saver. |
boolean |
isKeyColumnName(java.lang.String columnName)
Checks if is key column name. |
boolean |
isVersioning()
Checks if is versioning. |
java.util.Enumeration |
listOptions()
Lists the available options. |
static void |
main(java.lang.String[] options)
Main method. |
java.lang.String |
passwordTipText()
Returns the tip text for this property. |
java.lang.String |
relationForTableNameTipText()
Returns the tip text fo this property. |
void |
resetOptions()
Resets the Saver ready to save a new data set. |
void |
setAutoKeyGeneration(boolean flag)
En/Dis-ables the automatic generation of a primary key. |
void |
setDbWriteMode(java.lang.String dbWriteMode)
Sets the db write mode. |
void |
setDestination()
Sets the database url using the DatabaseUtils file. |
void |
setDestination(java.sql.Connection connection)
Sets the database url using the given connection. |
void |
setDestination(java.lang.String url)
Sets the database url. |
void |
setDestination(java.lang.String url,
java.lang.String userName,
java.lang.String password)
Sets the database url. |
void |
setKeyColumnNames(java.lang.String[] keyColumnNames)
Sets the key column names. |
void |
setOptions(java.lang.String[] options)
Sets the options. |
void |
setPassword(java.lang.String password)
Sets the database password. |
void |
setRelationForTableName(boolean flag)
En/Dis-ables that the relation name is used for the name of the table (default enabled). |
void |
setTableName(java.lang.String tn)
Sets the table's name. |
void |
setUrl(java.lang.String url)
Sets the database URL. |
void |
setUser(java.lang.String user)
Sets the database user. |
void |
setVersion(java.lang.String version)
Sets the version. |
void |
setVersionColumnName(java.lang.String versionColumnName)
Sets the version column name. |
void |
setVersioning(boolean versioning)
Sets the versioning. |
java.lang.String |
tableNameTipText()
Returns the tip text for this property. |
java.lang.String |
urlTipText()
Returns the tip text for this property. |
java.lang.String |
userTipText()
Returns the tip text for this property. |
void |
writeBatch()
Writes a Batch of instances. |
void |
writeIncremental(weka.core.Instance inst)
Saves an instances incrementally. |
Methods inherited from class weka.core.converters.AbstractSaver |
---|
filePrefix, getFileExtension, getInstances, getRetrieval, getWriteMode, resetStructure, retrieveDir, setDestination, setDestination, setDir, setDirAndPrefix, setFile, setFilePrefix, setInstances, setRetrieval, setStructure, setWriteMode |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static java.lang.String PROPERTY_FILE
protected static java.util.Properties PROPERTIES
protected int dbWriteMode
protected java.lang.String[] keyColumnNames
protected boolean versioning
protected java.lang.String versionColumnName
protected java.lang.String version
public static final int DROP_INSERT
public static final int DELETE_INSERT
public static final int INSERT
public static final int UPDATE_INSERT
Constructor Detail |
---|
public DatabaseSaver() throws java.lang.Exception
java.lang.Exception
- throws Exception if property file cannot be readMethod Detail |
---|
public void setDbWriteMode(java.lang.String dbWriteMode)
dbWriteMode
- the new db write modepublic void resetOptions()
resetOptions
in class weka.core.converters.AbstractSaver
public void cancel()
cancel
in class weka.core.converters.AbstractSaver
public java.lang.String globalInfo()
public void setTableName(java.lang.String tn)
tn
- the name of the tablepublic java.lang.String getTableName()
public java.lang.String tableNameTipText()
public void setAutoKeyGeneration(boolean flag)
flag
- flag for automatic key-genererationpublic boolean getAutoKeyGeneration()
public java.lang.String autoKeyGenerationTipText()
public void setRelationForTableName(boolean flag)
flag
- if true the relation name is used as table namepublic boolean getRelationForTableName()
public java.lang.String relationForTableNameTipText()
public void setUrl(java.lang.String url)
setUrl
in interface weka.core.converters.DatabaseConverter
url
- the URLpublic java.lang.String getUrl()
getUrl
in interface weka.core.converters.DatabaseConverter
public java.lang.String urlTipText()
public void setUser(java.lang.String user)
setUser
in interface weka.core.converters.DatabaseConverter
user
- the user namepublic java.lang.String getUser()
getUser
in interface weka.core.converters.DatabaseConverter
public java.lang.String userTipText()
public void setPassword(java.lang.String password)
setPassword
in interface weka.core.converters.DatabaseConverter
password
- the passwordpublic java.lang.String getPassword()
public java.lang.String passwordTipText()
public java.lang.String getVersion()
public void setVersion(java.lang.String version)
version
- the new versionpublic java.lang.String getVersionColumnName()
public void setVersionColumnName(java.lang.String versionColumnName)
versionColumnName
- the new version column namepublic boolean isVersioning()
public void setVersioning(boolean versioning)
versioning
- the new versioningpublic java.lang.String[] getKeyColumnNames()
public void setKeyColumnNames(java.lang.String[] keyColumnNames)
keyColumnNames
- the new key column namespublic void setDestination(java.lang.String url, java.lang.String userName, java.lang.String password)
url
- the database urluserName
- the user namepassword
- the passwordpublic void setDestination(java.lang.String url)
url
- the database urlpublic void setDestination()
public void setDestination(java.sql.Connection connection)
connection
- the connectionpublic weka.core.Capabilities getCapabilities()
getCapabilities
in interface weka.core.CapabilitiesHandler
getCapabilities
in class weka.core.converters.AbstractSaver
Capabilities
public void connectToDatabase()
public boolean isKeyColumnName(java.lang.String columnName)
columnName
- the column name
public void writeIncremental(weka.core.Instance inst) throws java.io.IOException
writeIncremental
in interface weka.core.converters.Saver
writeIncremental
in class weka.core.converters.AbstractSaver
inst
- the instance to save
java.io.IOException
- throws IOEXception.public void writeBatch() throws java.io.IOException
writeBatch
in interface weka.core.converters.Saver
writeBatch
in class weka.core.converters.AbstractSaver
java.io.IOException
- throws IOExceptionpublic java.lang.String[] getOptions()
getOptions
in interface weka.core.OptionHandler
public java.util.Enumeration listOptions()
listOptions
in interface weka.core.OptionHandler
public void setOptions(java.lang.String[] options) throws java.lang.Exception
-url <JDBC URL> The JDBC URL to connect to. (default: from DatabaseUtils.props file)
-user <name> The user to connect with to the database. (default: none)
-password <password> The password to connect with to the database. (default: none)
-T <table name> The name of the table. (default: the relation name)
-P Add an ID column as primary key. The name is specified in the DatabaseUtils file ('idColumn'). The DatabaseLoader won't load this column.
-i <input file name> Input file in arff format that should be saved in database.
setOptions
in interface weka.core.OptionHandler
options
- the options
java.lang.Exception
- if options cannot be setpublic java.lang.String getRevision()
getRevision
in interface weka.core.RevisionHandler
public static void main(java.lang.String[] options)
options
- should contain the options of a Saver.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |