Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "SMILA/Documentation/JdbcLoggingPipelet"

Line 1: Line 1:
== Bundle: <tt>org.eclipse.smila.jdbc</tt>  ==
+
= Bundle: <tt>org.eclipse.smila.jdbc</tt>  =
 +
== Bundle: <tt>org.eclipse.smila.jdbc.JdbcLoggingPipelet</tt>  ==
  
 
=== Description  ===
 
=== Description  ===
Line 90: Line 91:
  
 
</pre>  
 
</pre>  
 +
 +
 +
== Bundle: <tt>org.eclipse.smila.jdbc.JdbcFetcherPipelet</tt>  ==
 +
 +
=== Description  ===
 +
 +
The '''JdbcFetcherPipelet''' fetches the results of a given statement string (= PreparedStatement) from a database via JDBC for each processed record. The PreparedStatement typically has parameters '?', these are filled with the values which are referenced by the ''valuePaths'' parameter. The valuePaths parameter contains a list of strings, each string contains a path to a (sub-)attribute in the currently processed record's metadata.
 +
 +
=== Configuration  ===
 +
 +
{| border="1"
 +
|-
 +
! Property
 +
! Type
 +
! Read Type
 +
! Required
 +
! Description
 +
|-
 +
| ''dbUrl''
 +
| String
 +
| runtime
 +
| yes
 +
| The (JDBC driver) dependent URL which is used to connect to the database.
 +
|-
 +
| ''dbProps''
 +
| Map
 +
| runtime
 +
| yes
 +
| Database connection properties, e.g. 'user' and 'password'.
 +
|-
 +
| ''stmt''
 +
| String
 +
| runtime
 +
| yes
 +
| The (Prepared)Statement with the SELECT statement to fetch data from the database, may have parameters.
 +
|-
 +
| ''valuePaths''
 +
| String (multi)
 +
| runtime
 +
| no
 +
| List of paths which point to the record's metadata (sub)attributes that are used as parameter values in the SELECT statement. A path is separated by '/'.
 +
|}
 +
 +
===== Configuring value paths =====
 +
 +
The following should be taken into account when specifying a value path:
 +
 +
*If a value path references a single value, this is used for the PreparedStatement.
 +
*If a value path references a sequence of values, (only) the first value of the sequence is used.
 +
*In any other case, the value is set 'null'. (Keep in mind that a 'null' value is valid for a PreparedStatement)
 +
 +
The ''valuePaths'' parameter is optional, so it's ok to leave it empty, or to leave it at all. However, this must fit to the given SELECT statement, if no value paths are specified, the statement musn't have parameters.
 +
 +
=== Example  ===
 +
 +
The following example shows a sample pipelet configuration:
 +
 +
Pipelet configuration:
 +
<pre>
 +
  &lt;proc:configuration&gt;
 +
    &lt;rec:Val key="dbUrl"&gt;jdbc:postgresql://localhost/mydb&lt;/rec:Val&gt;
 +
    &lt;rec:Val key="stmt"&gt;SELECT COUNT(*) FROM myTable WHERE action=?&lt;/rec:Val&gt;
 +
    &lt;rec:Map key="dbProps"&gt;                   
 +
        &lt;rec:Val key="user"&gt;Andreas&lt;/rec:Val&gt;
 +
        &lt;rec:Val key="password"&gt;top_secret&lt;/rec:Val&gt;                                     
 +
    &lt;/rec:Map&gt;
 +
    &lt;rec:Seq key="valuePaths"&gt;
 +
          &lt;rec:Val&gt;Action&lt;/rec:Val&gt;
 +
    &lt;/rec:Seq&gt;
 +
  &lt;/proc:configuration&gt; 
 +
 +
</pre>
 
[[Category:SMILA]] [[Category:SMILA/Pipelet]]
 
[[Category:SMILA]] [[Category:SMILA/Pipelet]]

Revision as of 06:43, 25 February 2013

Bundle: org.eclipse.smila.jdbc

Bundle: org.eclipse.smila.jdbc.JdbcLoggingPipelet

Description

The JdbcLoggingPipelet logs a given statement string (= PreparedStatement) into a database via JDBC for each processed record. The PreparedStatement typically has parameters '?', these are filled with the values which are referenced by the valuePaths parameter. The valuePaths parameter contains a list of strings, each string contains a path to a (sub-)attribute in the currently processed record's metadata.

Configuration

Property Type Read Type Required Description
dbUrl String runtime yes The (JDBC driver) dependent URL which is used to connect to the database.
dbProps Map runtime yes Database connection properties, e.g. 'user' and 'password'.
stmt String runtime yes The (Prepared)Statement which is logged to the database, may have parameters.
valuePaths String (multi) runtime no List of paths which point to the record's metadata (sub)attributes that are used as parameter values in the logged statement. A path is separated by '/'.
Configuring value paths

The following should be taken into account when specifying a value path:

  • If a value path references a single value, this is used for the PreparedStatement.
  • If a value path references a sequence of values, (only) the first value of the sequence is used.
  • In any other case, the value is set 'null'. (Keep in mind that a 'null' value is valid for a PreparedStatement)

The valuePaths parameter is optional, so it's ok to leave it empty, or to leave it at all. However, this must fit to the given log statement, if no value paths are specified, the statement musn't have parameters.

Example

The following example shows a sample pipelet configuration and the resulting log statement when logging the given record.

Pipelet configuration:

   <proc:configuration>
     <rec:Val key="dbUrl">jdbc:postgresql://localhost/mydb</rec:Val>
     <rec:Val key="stmt">INSERT INTO myTable VALUES (?, ?, 100, ?, ?)</rec:Val>
     <rec:Map key="dbProps">                    
        <rec:Val key="user">Andreas</rec:Val>
        <rec:Val key="password">top_secret</rec:Val>                                      
     </rec:Map>
     <rec:Seq key="valuePaths">
          <rec:Val>_recordid</rec:Val>
          <rec:Val>_parameters/session/id</rec:Val>
          <rec:Val>Authors</rec:Val>
          <rec:Val>Size</rec:Val>
     </rec:Seq>
   </proc:configuration>   

Sample record and resulting logged SQL statement:

 {
   "_recordid":"web:http://example.org",   
   "_parameters": {
      "maxCount": 100,
      "session": {
         "timestamp": "2012-10-12T14:00:00",
         "id": 4711
      }
   }
   "Path": "http://example.org/index.html",
   "Authors": ["Andreas Weber", "Jürgen Schumacher", "Andreas Schank"]   
 }

-> INSERT INTO myTable VALUES ('web:http://example.org', 4711, 100, 'Andreas Weber', null)


Bundle: org.eclipse.smila.jdbc.JdbcFetcherPipelet

Description

The JdbcFetcherPipelet fetches the results of a given statement string (= PreparedStatement) from a database via JDBC for each processed record. The PreparedStatement typically has parameters '?', these are filled with the values which are referenced by the valuePaths parameter. The valuePaths parameter contains a list of strings, each string contains a path to a (sub-)attribute in the currently processed record's metadata.

Configuration

Property Type Read Type Required Description
dbUrl String runtime yes The (JDBC driver) dependent URL which is used to connect to the database.
dbProps Map runtime yes Database connection properties, e.g. 'user' and 'password'.
stmt String runtime yes The (Prepared)Statement with the SELECT statement to fetch data from the database, may have parameters.
valuePaths String (multi) runtime no List of paths which point to the record's metadata (sub)attributes that are used as parameter values in the SELECT statement. A path is separated by '/'.
Configuring value paths

The following should be taken into account when specifying a value path:

  • If a value path references a single value, this is used for the PreparedStatement.
  • If a value path references a sequence of values, (only) the first value of the sequence is used.
  • In any other case, the value is set 'null'. (Keep in mind that a 'null' value is valid for a PreparedStatement)

The valuePaths parameter is optional, so it's ok to leave it empty, or to leave it at all. However, this must fit to the given SELECT statement, if no value paths are specified, the statement musn't have parameters.

Example

The following example shows a sample pipelet configuration:

Pipelet configuration:

   <proc:configuration>
     <rec:Val key="dbUrl">jdbc:postgresql://localhost/mydb</rec:Val>
     <rec:Val key="stmt">SELECT COUNT(*) FROM myTable WHERE action=?</rec:Val>
     <rec:Map key="dbProps">                    
        <rec:Val key="user">Andreas</rec:Val>
        <rec:Val key="password">top_secret</rec:Val>                                      
     </rec:Map>
     <rec:Seq key="valuePaths">
          <rec:Val>Action</rec:Val>
     </rec:Seq>
   </proc:configuration>   

Copyright © Eclipse Foundation, Inc. All Rights Reserved.