database connector configuration

22
Database Connector Configuration Thanh Nguyen

Upload: cong-thanh-nguyen

Post on 12-Jan-2017

51 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Database connector configuration

Database Connector Configuration

Thanh Nguyen

Page 2: Database connector configuration

Adding a Generic Database Driver

• When using the Generic Database Configuration, you manually import the driver for your database engine into your application as a referenced library, or preferably add it as a Maven dependency

• ou can use the database connector with any database engine for which you have a driver

Page 3: Database connector configuration

Adding a Generic Database Driver

1. If you haven’t already done so, download the driver for your particular database. For example, the driver for a MySQL database is available to Download online.

2. Drag and drop the driver .jar file from your local drive to the root folder in your project or add the .jar file to the build path of your project via the wizard by right-clicking the project name, selecting Build Path > Configure Build Path….

Page 4: Database connector configuration

Adding a Generic Database Driver

3. In the wizard that appears, click the Libraries tab, then click Add Jars… (or Add External Jars…, depending on its location.

4. Click OK to save, then OK to exit the wizard. If referencing an external .jar, notice that your project now has a new folder named Referenced Libraries in which your database driver .jar resides

Page 5: Database connector configuration

Configuration for Generic DatabaseRequired Attribute UseName Use to define unique identifier

for the global database connector element in your application.

Configure via spring-bean Optional. Configure this database connection by the Spring bean referenced in DataSource Reference. Mutually exclusive with Database URL.

Page 6: Database connector configuration

Configuration for Generic Database

Database URL Optional (can also be configured with Configure via spring-bean). The URL for the database connection. Mutually exclusive with Configure via spring-bean.

Driver Class Name Fully-qualified driver class name of the driver for your database, which must be already imported into your project. You can enter the full name in the empty field or click …  to browse the available driver classes.

Page 7: Database connector configuration

Configuration for Generic Database

Page 8: Database connector configuration

Advanced Tab - Optional AttributesOptional Attributes Use

Advanced Parameters Send parameters as key-value pairs to your DB. The parameters that can be set depend on what database software you are connecting to.

Connection Timeout Define the amount of time a database connection remains securely active during a period of non-usage before timing-out and demanding logging in again.

Page 9: Database connector configuration

Advanced Tab - Optional AttributesConnection Pooling Define values for any of the

connection pooling attributes to customize how your database connector reuses connections to the database. You can define values for:•Max Pool Size•Min Pool Size•Acquire Increment•Prepared Statement Cache Size•Max Wait Millis

Use XA Transactions Enable to indicate that the created datasource must support extended architecture (XA) transactions. Default: false.

Page 10: Database connector configuration

Common Driver Class Specifications

Database Driver Version Driver Class Name

PostgreSQL postgresql-9.3-1101.jdbc3.jar

org.postgresql.Driver

MS-SQL sqljdbc4.jar com.microsoft.sqlserver.jdbc.SQLServerDriver

Page 11: Database connector configuration

Example Generic Database Connector Configuration for PostgreSQL

<db:generic-config name="Generic_Database_Configuration" url="jdbc:postgresql://localhost:5432/tictactoe?password=pass&user=yourusername" driverClassName="org.postgresql.Driver" doc:name="Generic Database Configuration"> </db:generic-config>

Page 12: Database connector configuration

Configuring a Database Connector Instance Inside a Flow

Required Attribute UseDisplay Name Use to define a unique identifier for the

Database Connector element in your flow.Config Reference Use to identify the global database

connector element to which the Database Connector refers for connection details, among other things.

Operation Use to instruct the Database Connector to submit a request to perform a specific query in the database:•Select•Insert•Update •Delete•Stored Procedure•Bulk Execute•Execute DDL

Page 13: Database connector configuration

Parameterized Stored Procedure Fields

• Parameter Name - Use to identify a named parameter in your SQL statement for which you wish to use the value at runtime, when your application submits your query which calls upon stored in the database instance.

• Parameter Type - Use to identify the type of data the stored procedure can expect to receive from your query statement.

• IN/OUT - Defines the use of your stored procedure’s parameter:– IN - Stored procedure that can expect only to receive data– OUT - Stored procedure that can expect only to return data– INOUT - Stored procedure that can expect to receive, then return

data

Page 14: Database connector configuration

Parameterized Stored Procedure Fields

• Value - Parameterized Stored Procedure. Use to define the value that overrides the default value for the named parameter in your SQL statement when your application submits your query

Page 15: Database connector configuration

Parameterized Stored Procedure Fields

Page 16: Database connector configuration

Bulk Execute Operation Parameters

• Query Text - Type several statements (separated by a semicolon and a new line character) to perform them in bulk. Supports all operations except Select and Stored procedure.

• From File - Reference a file with several statements (separated by a semicolon and a new line character) to perform them in bulk. Supports all operations except Select and Stored procedure.

Page 17: Database connector configuration

Bulk Execute Operation Parameters

Page 18: Database connector configuration

Execute DDL Operation Parameters

• Dynamic query - Use with: Execute DDL. Perform an operation on the data structure, rather than the data itself through a DDL request

Page 19: Database connector configuration

Fields to Use With All Operations

• Target • Query Timeout• Source• Transactional Action– JOIN_IF_POSSIBLE– ALWAYS_JOIN– NOT_SUPPORTED

Page 20: Database connector configuration

Fields to Use With All Operations

• Select and Stored Procedure Fields– Max Rows– Fetch Size – Streaming

• Insert, Update, and Delete Fields– Bulk Mode

Page 21: Database connector configuration

Insert Fields

• Auto-generated Keys• Auto-generated Keys Column Indexes• Auto-generated Keys Column Names

Page 22: Database connector configuration

Question and answer