-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Add][plugin][reader] Add support for Access Database (#931)
- Loading branch information
Showing
13 changed files
with
314 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"job": { | ||
"setting": { | ||
"speed": { | ||
"byte": -1, | ||
"channel": 1 | ||
} | ||
}, | ||
"content": [ | ||
{ | ||
"reader": { | ||
"name": "accessreader", | ||
"parameter": { | ||
"username": "root", | ||
"password": "", | ||
"column": [ | ||
"*" | ||
], | ||
"connection": [ | ||
{ | ||
"table": [ | ||
"tbl_Users" | ||
], | ||
"jdbcUrl": [ | ||
"jdbc:ucanaccess:///Users/wgzhao/Downloads/AccessThemeDemo.mdb" | ||
] | ||
} | ||
], | ||
"where": "" | ||
} | ||
}, | ||
"writer": { | ||
"name": "streamwriter", | ||
"parameter": { | ||
"encoding": "utf-8", | ||
"print": true | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Access Reader | ||
|
||
AccessReader 实现了从 [Access][1] 数据库上读取数据的能力,他基于 [Addax RDBMS Reader][2] 实现。 | ||
|
||
## 示例 | ||
|
||
我们下载用于测试用的 [Acess Demo](http://www.databasedev.co.uk/downloads/AccessThemeDemo.zip) 文件,解药后得到 `AccessThemeDemo.mdb` 文件,该文件中包含了一个 `tbl_Users` 表,我们将该表的数据同步到终端上。 | ||
|
||
下面的配置是读取该表到终端的作业: | ||
|
||
=== "job/access2stream.json" | ||
|
||
```json | ||
--8<-- "jobs/accessreader.json" | ||
``` | ||
|
||
将上述配置文件保存为 `job/access2stream.json` | ||
|
||
### 执行采集命令 | ||
|
||
执行以下命令进行数据采集 | ||
|
||
```shell | ||
bin/addax.sh job/access2stream.json | ||
``` | ||
|
||
## 参数说明 | ||
|
||
因本插件基于[Addax RDBMS Reader][2] 实现,所以参数说明请参考 [Addax RDBMS Reader][2]。 | ||
|
||
[1]: https://en.wikipedia.org/wiki/Microsoft_Access | ||
[2]: ../rdbmsreader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<assembly | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" | ||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-component-1.1.2.xsd"> | ||
<id>release</id> | ||
<formats> | ||
<format>dir</format> | ||
</formats> | ||
<includeBaseDirectory>false</includeBaseDirectory> | ||
<fileSets> | ||
<fileSet> | ||
<directory>src/main/resources</directory> | ||
<includes> | ||
<include>*.json</include> | ||
</includes> | ||
<outputDirectory>plugin/reader/${project.artifactId}</outputDirectory> | ||
</fileSet> | ||
<fileSet> | ||
<directory>target/</directory> | ||
<includes> | ||
<include>${project.artifactId}-${project.version}.jar</include> | ||
</includes> | ||
<outputDirectory>plugin/reader/${project.artifactId}</outputDirectory> | ||
</fileSet> | ||
</fileSets> | ||
|
||
<dependencySets> | ||
<dependencySet> | ||
<useProjectArtifact>false</useProjectArtifact> | ||
<outputDirectory>plugin/reader/${project.artifactId}/libs</outputDirectory> | ||
<scope>runtime</scope> | ||
<excludes> | ||
<exclude>com.wgzhao.addax:*</exclude> | ||
</excludes> | ||
</dependencySet> | ||
</dependencySets> | ||
</assembly> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.wgzhao.addax</groupId> | ||
<artifactId>addax-all</artifactId> | ||
<version>4.1.3-SNAPSHOT</version> | ||
<relativePath>../../../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>accessreader</artifactId> | ||
<name>access-reader</name> | ||
<packaging>jar</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.wgzhao.addax</groupId> | ||
<artifactId>addax-common</artifactId> | ||
<version>${project.version}</version> | ||
<exclusions> | ||
<exclusion> | ||
<artifactId>slf4j-log4j12</artifactId> | ||
<groupId>org.slf4j</groupId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.wgzhao.addax</groupId> | ||
<artifactId>addax-rdbms</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>net.sf.ucanaccess</groupId> | ||
<artifactId>ucanaccess</artifactId> | ||
<version>5.0.1</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<configuration> | ||
<descriptors> | ||
<descriptor>package.xml</descriptor> | ||
</descriptors> | ||
<finalName>${project.artifactId}-${project.version}</finalName> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>release</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
75 changes: 75 additions & 0 deletions
75
.../accessreader/src/main/java/com/wgzhao/addax/plugin/reader/accessreader/AccessReader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.wgzhao.addax.plugin.reader.accessreader; | ||
|
||
import com.wgzhao.addax.common.base.Constant; | ||
import com.wgzhao.addax.common.base.Key; | ||
import com.wgzhao.addax.common.plugin.RecordSender; | ||
import com.wgzhao.addax.common.spi.Reader; | ||
import com.wgzhao.addax.common.util.Configuration; | ||
import com.wgzhao.addax.rdbms.reader.CommonRdbmsReader; | ||
import com.wgzhao.addax.rdbms.util.DataBaseType; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.List; | ||
|
||
public class AccessReader extends Reader { | ||
private static final DataBaseType DATABASE_TYPE = DataBaseType.Access; | ||
|
||
public static class Job extends Reader.Job { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(Job.class); | ||
|
||
private Configuration configuration = null; | ||
|
||
private CommonRdbmsReader.Job commonRdbmsReaderJob; | ||
|
||
@Override | ||
public void init() { | ||
this.configuration = getPluginJobConf(); | ||
this.commonRdbmsReaderJob = new CommonRdbmsReader.Job(DATABASE_TYPE); | ||
this.configuration = this.commonRdbmsReaderJob.init(this.configuration); | ||
} | ||
|
||
@Override | ||
public void preCheck() { | ||
this.commonRdbmsReaderJob.preCheck(this.configuration, DATABASE_TYPE); | ||
} | ||
|
||
@Override | ||
public void destroy() { | ||
this.commonRdbmsReaderJob.destroy(this.configuration); | ||
} | ||
|
||
@Override | ||
public List<Configuration> split(int adviceNumber) { | ||
return this.commonRdbmsReaderJob.split(this.configuration, adviceNumber); | ||
} | ||
} | ||
|
||
public static class Task extends Reader.Task { | ||
|
||
private Configuration configuration = null; | ||
private CommonRdbmsReader.Task commonRdbmsReaderTask; | ||
|
||
@Override | ||
public void startRead(RecordSender recordSender) { | ||
|
||
int fetchSize = this.configuration.getInt(Key.FETCH_SIZE, Constant.DEFAULT_FETCH_SIZE); | ||
this.commonRdbmsReaderTask.startRead(this.configuration, recordSender, this.getTaskPluginCollector(), fetchSize); | ||
} | ||
|
||
@Override | ||
public void init() { | ||
this.configuration = getPluginJobConf(); | ||
this.commonRdbmsReaderTask = new CommonRdbmsReader.Task(DATABASE_TYPE, getTaskGroupId(), getTaskId()); | ||
this.commonRdbmsReaderTask.init(this.configuration); | ||
} | ||
|
||
@Override | ||
public void destroy() { | ||
|
||
this.commonRdbmsReaderTask.destroy(this.configuration); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "accessreader", | ||
"class": "com.wgzhao.addax.plugin.reader.accessreader.AccessReader", | ||
"description": "access reader", | ||
"developer": "wgzhao" | ||
} |
21 changes: 21 additions & 0 deletions
21
plugin/reader/accessreader/src/main/resources/plugin_job_template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "accessreader", | ||
"parameter": { | ||
"username": "root", | ||
"password": "root", | ||
"column": [ | ||
"*" | ||
], | ||
"connection": [ | ||
{ | ||
"table": [ | ||
"addax_reader" | ||
], | ||
"jdbcUrl": [ | ||
"jdbc:ucanaccess://<mdb or accdb file path>" | ||
] | ||
} | ||
], | ||
"where": "" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters