Menu

Joone JDBC

2008-12-04
2013-04-16
  • Nobody/Anonymous

    Are there any examples of extracting data from a database using JBDC in Joone

     
    • UeliHofstetter

      UeliHofstetter - 2008-12-05

      hi,

      i don't think that it is anywhere used in the code samples. but anyway, the documentation in the sourcecode is quite comprehensive (see below), so its use should be quite straight forward.

      kind regards

      u

      /**
      * <P>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.</P>
      * <P>The properties required by this JDBCInputSynapse Plugin are the following</P>
      * <P>Database Driver Name - e.g sun.jdbc.odbc.JdbcOdbcDriver</P>
      * <P>Database URL - e.g jdbc:mysql://localhost/MyDb?user=myuser&password=mypass
      * <P>SQLquery - e.g select val1,val2,result from xor;</P>
      * <P>Advanced Column Selector - This selects the values from the query result e.g '1,2' would
      * select val1 and val2. in this case.
      * <P>Note : The database URL uses specific protocol after the "jdbc:" section check with the jdbc driver vendor for specific info.</P>
      * <P>Some commonly used Driver protocols shown below ...</P>
      * <BR>
      * <P>Driver {com.mysql.jdbc.Driver} </P>
      * <P>Protocol {jdbc:mysql://[hostname][,failoverhost...][:port]/[dbname][?param1=value1][&param2=value2].....} MySQL Protool </P>
      * <P>Example {jdbc:mysql://localhost/test?user=blah&password=blah} </P>
      * <P>Web Site {http://www.mysql.com} </P>
      * <BR>
      * <P>Driver {sun.jdbc.odbc.JdbcOdbcDriver} </P>
      * <P>Protocol { jdbc:odbc:<data-source-name>[;<attribute-name>=<attribute-value>]* }  ODBC Protocol </P>
      * <P>Example {jdbc:odbc:mydb;UID=me;PWD=secret} </P>
      * <P>Web Site {http://www.java.sun.com} </P>
      * <BR>
      * <P>Data Types</P>
      * <BR>
      * <P>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.</P>
      * <P>E.g Correct = '2.31' Wrong= '3.45;1.21' and Wrong = 'hello' </P>
      *
      * @author     Julien Norman
      * @created    29/11/2002
      */
      public class JDBCInputSynapse extends StreamInputSynapse {
         
          /** The object used when logging debug,errors,warnings and info. */
          private static final ILogger log = LoggerFactory.getLogger(JDBCInputSynapse.class);
         
          /** The name of the JDBC Database driver. */
          private String driverName = "";
          /** The URL of the database. */
          private String dbURL = "";
          /** The database query to use in order to obtain the input data. */
          private String SQLQuery = "";
         
          private final static long serialVersionUID =  -4642657913289986240L;
         
          /**
           *Constructor for the JDBCInputSynapse object
           */
          public JDBCInputSynapse() {
              super();
          }
         
          /**
           * <P>Constructor for the JDBCInputSynapse object that allows all options.
           * Allows the user to construct a JDBCInputSynapse in one call.</P>
           * @param newDrivername The class name of the database driver to use.
           * @param newdbURL The Universal Resource Locator to enable connection to the database.
           * @param newSQLQuery The database SQL query to apply to the database.
           * @param newAdvColSel The comma delimited selection of what data columns to use.
           * @param newfirstRow The first row to apply to the network.
           * @param newlastRow The last row to apply to the network.
           * @param buffered Whether this synapse is buffered or not.
           */
          public JDBCInputSynapse(String newDrivername,String newdbURL, String newSQLQuery,String newAdvColSel,int newfirstRow,int newlastRow,boolean buffered) {
              super();
             
              setBuffered(buffered);
              setFirstRow(newfirstRow);
              setLastRow(newlastRow);
              setAdvancedColumnSelector(newAdvColSel);
              setdriverName(newDrivername);
              setdbURL(newdbURL);
              setSQLQuery(newSQLQuery);
             
          }

       

Log in to post a comment.