Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.joone.io
Class JDBCInputSynapse  view JDBCInputSynapse download JDBCInputSynapse.java

java.lang.Object
  extended byorg.joone.engine.Synapse
      extended byorg.joone.io.StreamInputSynapse
          extended byorg.joone.io.JDBCInputSynapse
All Implemented Interfaces:
org.joone.engine.InputPatternListener, InputSynapse, org.joone.inspection.Inspectable, org.joone.engine.Learnable, org.joone.engine.LearnableSynapse, org.joone.engine.NeuralElement, org.joone.engine.OutputPatternListener, org.joone.util.PlugInListener, java.io.Serializable

public class JDBCInputSynapse
extends StreamInputSynapse

The JDBCInputSynapse provides support for data extraction from a database. To use this synapse the user should ensure a JDBC Type 4 Driver is in the class path. It is possible to use other JDBC driver types though you will have to refer to the vendors documentation, it may require extra software insallation and this may limit your distributtion to certain Operating Systems.

The properties required by this JDBCInputSynapse Plugin are the following

Database Driver Name - e.g sun.jdbc.odbc.JdbcOdbcDriver

Database URL - e.g jdbc:mysql://localhost/MyDb?user=myuser&password=mypass

SQLquery - e.g select val1,val2,result from xor;

Advanced Column Selector - This selects the values from the query result e.g '1,2' would select val1 and val2. in this case.

Note : The database URL uses specific protocol after the "jdbc:" section check with the jdbc driver vendor for specific info.

Some commonly used Driver protocols shown below ...


Driver {com.mysql.jdbc.Driver}

Protocol {jdbc:mysql://[hostname][,failoverhost...][:port]/[dbname][?param1=value1][¶m2=value2].....} MySQL Protool

Example {jdbc:mysql://localhost/test?user=blah&password=blah}

Web Site {http://www.mysql.com}


Driver {sun.jdbc.odbc.JdbcOdbcDriver}

Protocol { jdbc:odbc:[;=]* } ODBC Protocol

Example {jdbc:odbc:mydb;UID=me;PWD=secret}

Web Site {http://www.java.sun.com}


Data Types


Any fields selected from a database should contain a single double or float format value. The data type is not so important it can be text or a number field so long as it contains just one double or float format value.

E.g Correct = '2.31' Wrong= '3.45;1.21' and Wrong = 'hello'


Field Summary
private  java.lang.String dbURL
          The URL of the database.
private  java.lang.String driverName
          The name of the JDBC Database driver.
private static org.joone.log.ILogger log
          The object used when logging debug,errors,warnings and info.
private static long serialVersionUID
           
private  java.lang.String SQLQuery
          The database query to use in order to obtain the input data.
 
Fields inherited from class org.joone.io.StreamInputSynapse
cols, currentRow, EOF, InputVector, plugInListeners, tokens
 
Fields inherited from class org.joone.engine.Synapse
array, b_pattern, bitems, bouts, count, enabled, fwdLock, inps, items, learnable, m_batch, m_pattern, myLearner, notFirstTime, notFirstTimeB, outs, revLock
 
Constructor Summary
JDBCInputSynapse()
          Constructor for the JDBCInputSynapse object
JDBCInputSynapse(java.lang.String newDrivername, java.lang.String newdbURL, java.lang.String newSQLQuery, java.lang.String newAdvColSel, int newfirstRow, int newlastRow, boolean buffered)
          Constructor for the JDBCInputSynapse object that allows all options.
 
Method Summary
 java.util.TreeSet check()
          Check that parameters are set correctly for the this JDBCInputSynapse object.
 java.lang.String getdbURL()
          Gets the name of the database Universal Resource Location (URL)
 java.lang.String getdriverName()
          Gets the name of the database jdbc driver used by this JDBC input syanpse.
 java.lang.String getSQLQuery()
          Gets the SQL Query used to select data from the database.
protected  void initInputStream()
          Connects to the database using Driver name and db URL and selects data using the SQLQuery.
private  void readObject(java.io.ObjectInputStream in)
          Reads this JDBCInputSynapse object into memory
 void setdbURL(java.lang.String newdbURL)
          Gets the name of the database Universal Resource Location (URL)
 void setdriverName(java.lang.String newDriverName)
          Sets the name of the database jdbc driver.
 void setSQLQuery(java.lang.String newSQLQuery)
          Sets the sQLQuery attribute of the JDBCInputSynapse object
private  void writeObject(java.io.ObjectOutputStream out)
          Writes this JDBCSynapseInput object to the ObjectOutputStream out.
 
Methods inherited from class org.joone.io.StreamInputSynapse
addPlugIn, addPlugInListener, backward, dataChanged, fireDataChanged, forward, fwdGet, fwdGet, getAdvancedColumnSelector, getAllPlugInListeners, getCurrentRow, getDecimalPoint, getFirstCol, getFirstRow, getInputPatterns, getInputVector, getLastCol, getLastRow, getMaxBufSize, getPlugIn, getStream, getTokens, gotoFirstLine, gotoLine, InspectableTitle, Inspections, isBuffered, isEOF, isStepCounter, numColumns, readAll, readObjectBase, removeAllPlugIns, removePlugInListener, reset, resetInput, revPut, setAdvancedColumnSelector, setArrays, setBuffered, setColList, setDecimalPoint, setDimensions, setEOF, setFirstCol, setFirstRow, setInputPatterns, setLastCol, setLastRow, setMaxBufSize, setPlugin, setPlugIn, setStepCounter, setTokens, writeObjectBase, zeroPattern
 
Methods inherited from class org.joone.engine.Synapse
addNoise, canCountSteps, fwdPut, getFwdLock, getIgnoreBefore, getInputDimension, getLearner, getLearningRate, getMomentum, getMonitor, getName, getOutputDimension, getRevLock, getWeights, init, initLearner, isEnabled, isInputFull, isLoopBack, isOutputFull, randomize, readResolve, revGet, setEnabled, setIgnoreBefore, setInputDimension, setInputFull, setLearningRate, setLoopBack, setMomentum, setMonitor, setName, setOutputDimension, setOutputFull, setWeights
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.joone.log.ILogger log
The object used when logging debug,errors,warnings and info.


driverName

private java.lang.String driverName
The name of the JDBC Database driver.


dbURL

private java.lang.String dbURL
The URL of the database.


SQLQuery

private java.lang.String SQLQuery
The database query to use in order to obtain the input data.


serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

JDBCInputSynapse

public JDBCInputSynapse()
Constructor for the JDBCInputSynapse object


JDBCInputSynapse

public JDBCInputSynapse(java.lang.String newDrivername,
                        java.lang.String newdbURL,
                        java.lang.String newSQLQuery,
                        java.lang.String newAdvColSel,
                        int newfirstRow,
                        int newlastRow,
                        boolean buffered)

Constructor for the JDBCInputSynapse object that allows all options. Allows the user to construct a JDBCInputSynapse in one call.

Method Detail

getdriverName

public java.lang.String getdriverName()
Gets the name of the database jdbc driver used by this JDBC input syanpse.


getdbURL

public java.lang.String getdbURL()
Gets the name of the database Universal Resource Location (URL)


getSQLQuery

public java.lang.String getSQLQuery()
Gets the SQL Query used to select data from the database.


readObject

private void readObject(java.io.ObjectInputStream in)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Reads this JDBCInputSynapse object into memory


setdriverName

public void setdriverName(java.lang.String newDriverName)
Sets the name of the database jdbc driver.


setdbURL

public void setdbURL(java.lang.String newdbURL)
Gets the name of the database Universal Resource Location (URL)


setSQLQuery

public void setSQLQuery(java.lang.String newSQLQuery)
Sets the sQLQuery attribute of the JDBCInputSynapse object


writeObject

private void writeObject(java.io.ObjectOutputStream out)
                  throws java.io.IOException
Writes this JDBCSynapseInput object to the ObjectOutputStream out.


initInputStream

protected void initInputStream()
                        throws org.joone.exception.JooneRuntimeException
Connects to the database using Driver name and db URL and selects data using the SQLQuery.

Specified by:
initInputStream in class StreamInputSynapse

check

public java.util.TreeSet check()
Check that parameters are set correctly for the this JDBCInputSynapse object.

Specified by:
check in interface org.joone.engine.NeuralElement
Overrides:
check in class StreamInputSynapse