类 DatabaseSaver

java.lang.Object
weka.core.converters.AbstractSaver
weka.core.converters.DatabaseSaver
所有已实现的接口:
Serializable, CapabilitiesHandler, BatchConverter, DatabaseConverter, IncrementalConverter, Saver, OptionHandler, RevisionHandler

public class DatabaseSaver extends AbstractSaver implements BatchConverter, IncrementalConverter, DatabaseConverter, OptionHandler
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.
版本:
$Revision: 7499 $
作者:
Stefan Mutter (mutter@cs.waikato.ac.nz)
另请参阅:
  • 构造器详细资料

    • DatabaseSaver

      public DatabaseSaver() throws Exception
      Constructor.
      抛出:
      Exception - throws Exception if property file cannot be read
  • 方法详细资料

    • resetOptions

      public void resetOptions()
      Resets the Saver ready to save a new data set.
      覆盖:
      resetOptions 在类中 AbstractSaver
    • cancel

      public void cancel()
      Cancels the incremental saving process and tries to drop the table if the write mode is CANCEL.
      覆盖:
      cancel 在类中 AbstractSaver
    • globalInfo

      public String globalInfo()
      Returns a string describing this Saver.
      返回:
      a description of the Saver suitable for displaying in the explorer/experimenter gui
    • setTableName

      public void setTableName(String tn)
      Sets the table's name.
      参数:
      tn - the name of the table
    • getTableName

      public String getTableName()
      Gets the table's name.
      返回:
      the table's name
    • tableNameTipText

      public String tableNameTipText()
      Returns the tip text for this property.
      返回:
      the tip text for this property
    • setAutoKeyGeneration

      public void setAutoKeyGeneration(boolean flag)
      En/Dis-ables the automatic generation of a primary key.
      参数:
      flag - flag for automatic key-genereration
    • getAutoKeyGeneration

      public boolean getAutoKeyGeneration()
      Gets whether or not a primary key will be generated automatically.
      返回:
      true if a primary key column will be generated, false otherwise
    • autoKeyGenerationTipText

      public String autoKeyGenerationTipText()
      Returns the tip text for this property.
      返回:
      tip text for this property
    • setRelationForTableName

      public void setRelationForTableName(boolean flag)
      En/Dis-ables that the relation name is used for the name of the table (default enabled).
      参数:
      flag - if true the relation name is used as table name
    • getRelationForTableName

      public boolean getRelationForTableName()
      Gets whether or not the relation name is used as name of the table.
      返回:
      true if the relation name is used as the name of the table, false otherwise
    • relationForTableNameTipText

      public String relationForTableNameTipText()
      Returns the tip text fo this property.
      返回:
      the tip text for this property
    • setUrl

      public void setUrl(String url)
      Sets the database URL.
      指定者:
      setUrl 在接口中 DatabaseConverter
      参数:
      url - the URL
    • getUrl

      public String getUrl()
      Gets the database URL.
      指定者:
      getUrl 在接口中 DatabaseConverter
      返回:
      the URL
    • urlTipText

      public String urlTipText()
      Returns the tip text for this property.
      返回:
      the tip text for this property
    • setUser

      public void setUser(String user)
      Sets the database user.
      指定者:
      setUser 在接口中 DatabaseConverter
      参数:
      user - the user name
    • getUser

      public String getUser()
      Gets the database user.
      指定者:
      getUser 在接口中 DatabaseConverter
      返回:
      the user name
    • userTipText

      public String userTipText()
      Returns the tip text for this property.
      返回:
      the tip text for this property
    • setPassword

      public void setPassword(String password)
      Sets the database password.
      指定者:
      setPassword 在接口中 DatabaseConverter
      参数:
      password - the password
    • getPassword

      public String getPassword()
      Returns the database password.
      返回:
      the database password
    • passwordTipText

      public String passwordTipText()
      Returns the tip text for this property.
      返回:
      the tip text for this property
    • setDestination

      public void setDestination(String url, String userName, String password)
      Sets the database url.
      参数:
      url - the database url
      userName - the user name
      password - the password
    • setDestination

      public void setDestination(String url)
      Sets the database url.
      参数:
      url - the database url
    • setDestination

      public void setDestination()
      Sets the database url using the DatabaseUtils file.
    • getCapabilities

      public Capabilities getCapabilities()
      Returns the Capabilities of this saver.
      指定者:
      getCapabilities 在接口中 CapabilitiesHandler
      覆盖:
      getCapabilities 在类中 AbstractSaver
      返回:
      the capabilities of this object
      另请参阅:
    • connectToDatabase

      public void connectToDatabase()
      Opens a connection to the database.
    • writeIncremental

      public void writeIncremental(Instance inst) throws IOException
      Saves an instances incrementally. Structure has to be set by using the setStructure() method or setInstances() method. When a structure is set, a table is created.
      指定者:
      writeIncremental 在接口中 Saver
      覆盖:
      writeIncremental 在类中 AbstractSaver
      参数:
      inst - the instance to save
      抛出:
      IOException - throws IOEXception.
    • writeBatch

      public void writeBatch() throws IOException
      Writes a Batch of instances.
      指定者:
      writeBatch 在接口中 Saver
      指定者:
      writeBatch 在类中 AbstractSaver
      抛出:
      IOException - throws IOException
    • getOptions

      public String[] getOptions()
      Gets the setting.
      指定者:
      getOptions 在接口中 OptionHandler
      返回:
      the current setting
    • listOptions

      public Enumeration listOptions()
      Lists the available options.
      指定者:
      listOptions 在接口中 OptionHandler
      返回:
      an enumeration of the available options
    • setOptions

      public void setOptions(String[] options) throws Exception
      Sets the options.

      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.
      指定者:
      setOptions 在接口中 OptionHandler
      参数:
      options - the options
      抛出:
      Exception - if options cannot be set
    • getRevision

      public String getRevision()
      Returns the revision string.
      指定者:
      getRevision 在接口中 RevisionHandler
      返回:
      the revision
    • main

      public static void main(String[] options)
      Main method.
      参数:
      options - should contain the options of a Saver.