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:
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'
cols, currentRow, EOF, InputVector, plugInListeners, tokens
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
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
|
addPlugIn, addPlugInListener, backward, dataChanged, fireDataChanged, forward, fwdGet, fwdGet, getAdvancedColumnSelector, getAllPlugInListeners, getCurrentRow, getDecimalPoint, getFirstCol, getFirstRow, getInputPatterns, getInputVector, getLastCol, getLastRow, getMaxBufSize, getPlugIn, getStream, getTokens, gotoFirstLine, gotoLine, handleExceptionWithError, handleExceptionWithWarn, InspectableTitle, Inspections, isBuffered, isEOF, isStepCounter, numColumns, readAll, readObjectBase, removeAllPlugIns, removePlugInListener, reset, resetInput, restart, revPut, setAdvancedColumnSelector, setArrays, setBuffered, setColList, setDecimalPoint, setDimensions, setEOF, setFirstCol, setFirstRow, setInputPatterns, setLastCol, setLastRow, setMaxBufSize, setPlugin, setPlugIn, setStepCounter, setTokens, writeObjectBase, zeroPattern
addNoise, canCountSteps, fwdPattern_consume, fwdPattern_produce, fwdPut, getCount, getFwdLock, getIgnoreBefore, getInputDimension, getLearner, getLearningRate, getMomentum, getMonitor, getName, getOutputDimension, getRevLock, getSynapseNameSafely, getWeights, init, initLearner, isEnabled, isInputFull, isLoopBack, isOutputFull, randomize, readResolve, revGet, revPattern_consume, revPattern_produce, setEnabled, setIgnoreBefore, setInputDimension, setInputFull, setLearningRate, setLoopBack, setMomentum, setMonitor, setName, setOutputDimension, setOutputFull, setWeights, warnLogger, warnLogger
public 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.
newDrivername
- The class name of the database driver to use.newdbURL
- The Universal Resource Locator to enable connection to the database.newSQLQuery
- The database SQL query to apply to the database.newAdvColSel
- The comma delimited selection of what data columns to use.newfirstRow
- The first row to apply to the network.newlastRow
- The last row to apply to the network.buffered
- Whether this synapse is buffered or not.public java.lang.String getdriverName()
public java.lang.String getdbURL()
public java.lang.String getSQLQuery()
public void setdriverName(java.lang.String newDriverName)
newDriverName
- The JDBC Driver namepublic void setdbURL(java.lang.String newdbURL)
newdbURL
- The database URL to use for selecting input. See the notes on this class for usage.public void setSQLQuery(java.lang.String newSQLQuery)
newSQLQuery
- The new database SQL Query.protected void initInputStream() throws JooneRuntimeException
initInputStream
in class StreamInputSynapse
JooneRuntimeException
public java.util.TreeSet check()
check
in interface NeuralElement
check
in class StreamInputSynapse
Synapse
Submit Feedback to pmarrone@users.sourceforge.net