Skip to content

Commit

Permalink
[BEAM-244] Add JDBC IO
Browse files Browse the repository at this point in the history
  • Loading branch information
jbonofre committed Sep 11, 2016
1 parent 49208ca commit 6d77b13
Show file tree
Hide file tree
Showing 7 changed files with 1,104 additions and 0 deletions.
125 changes: 125 additions & 0 deletions sdks/java/io/jdbc/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<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>org.apache.beam</groupId>
<artifactId>beam-sdks-java-io-parent</artifactId>
<version>0.3.0-incubating-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>beam-sdks-java-io-jdbc</artifactId>
<name>Apache Beam :: SDKs :: Java :: IO :: JDBC</name>
<description>IO to read and write on JDBC datasource.</description>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-sdks-java-core</artifactId>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.12.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.12.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbynet</artifactId>
<version>10.12.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-runners-direct-java</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.beam.sdk.io.jdbc;

import java.io.Serializable;

/**
* Container for JDBC data, providing the data details (column name, table name, payload, data
* type).
*/
public class JdbcDataRecord implements Serializable {

private String[] tableNames;
private String[] columnNames;
private Object[] columnValues;
private int[] columnTypes;

public JdbcDataRecord() {
}

public JdbcDataRecord(int size) {
this.tableNames = new String[size];
this.columnNames = new String[size];
this.columnValues = new Object[size];
this.columnTypes = new int[size];
}

public String[] getTableNames() {
return tableNames;
}

public void setTableNames(String[] tableName) {
this.tableNames = tableName;
}

public String[] getColumnNames() {
return columnNames;
}

public void setColumnNames(String[] columnNames) {
this.columnNames = columnNames;
}

public Object[] getColumnValues() {
return columnValues;
}

public void setColumnValues(Object[] columnValues) {
this.columnValues = columnValues;
}

public int[] getColumnTypes() {
return columnTypes;
}

public void setColumnTypes(int[] columnTypes) {
this.columnTypes = columnTypes;
}

public String toString() {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < tableNames.length; i++) {
builder.append("Table: ").append(tableNames[i]).append(" | Column: ")
.append(columnNames[i]).append(" | Type: ").append(columnTypes[i])
.append(" | Value: ").append(columnValues[i]).append("\n");
}
return builder.toString();
}

}
Loading

0 comments on commit 6d77b13

Please sign in to comment.