mirror of
https://github.com/apache/sqoop.git
synced 2025-05-05 06:12:25 +08:00
SQOOP-909: Sqoop2 integration: Create Oracle and Microsoft SQL Server database providers
(Jarek Jarcec Cecho via Kathleen Ting)
This commit is contained in:
parent
b49b71235d
commit
2237d94e66
12
pom.xml
12
pom.xml
@ -108,6 +108,8 @@ limitations under the License.
|
|||||||
<tomcat.version>${tomcat.major.version}.${tomcat.minor.version}</tomcat.version>
|
<tomcat.version>${tomcat.major.version}.${tomcat.minor.version}</tomcat.version>
|
||||||
<jdbc.mysql.version>5.1.23</jdbc.mysql.version>
|
<jdbc.mysql.version>5.1.23</jdbc.mysql.version>
|
||||||
<jdbc.postgresql.version>9.1-901.jdbc4</jdbc.postgresql.version>
|
<jdbc.postgresql.version>9.1-901.jdbc4</jdbc.postgresql.version>
|
||||||
|
<jdbc.oracle.version>11.2.0.3</jdbc.oracle.version>
|
||||||
|
<jdbc.sqlserver.version>4.0</jdbc.sqlserver.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -362,6 +364,16 @@ limitations under the License.
|
|||||||
<artifactId>postgresql</artifactId>
|
<artifactId>postgresql</artifactId>
|
||||||
<version>${jdbc.postgresql.version}</version>
|
<version>${jdbc.postgresql.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.oracle</groupId>
|
||||||
|
<artifactId>ojdbc14</artifactId>
|
||||||
|
<version>${jdbc.oracle.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.microsoft</groupId>
|
||||||
|
<artifactId>sqljdbc4</artifactId>
|
||||||
|
<version>${jdbc.sqlserver.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
47
test/pom.xml
47
test/pom.xml
@ -228,6 +228,53 @@ limitations under the License.
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
|
<!-- Special JDBC Drivers -->
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Oracle JDBC Driver
|
||||||
|
Install: mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=11.2.0.3 -Dpackaging=jar -Dfile=/path/to/the/jar/ojdbc6.jar
|
||||||
|
Usage: mvn integration-test -Djdbc.oracle
|
||||||
|
-->
|
||||||
|
<profile>
|
||||||
|
<id>jdbc-oracle</id>
|
||||||
|
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>jdbc.oracle</name>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.oracle</groupId>
|
||||||
|
<artifactId>ojdbc14</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</profile>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Microsoft SQL Server JDBC Driver
|
||||||
|
Install: mvn install:install-file -DgroupId=com.microsoft -DartifactId=sqljdbc4 -Dversion=4.0 -Dpackaging=jar -Dfile=/path/to/the/jar/sqljdbc4.jar
|
||||||
|
Usage: mvn integration-test -Djdbc.sqlserver
|
||||||
|
-->
|
||||||
|
<profile>
|
||||||
|
<id>jdbc-sqlserver</id>
|
||||||
|
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>jdbc.sqlserver</name>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.microsoft</groupId>
|
||||||
|
<artifactId>sqljdbc4</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</profile>
|
||||||
|
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -0,0 +1,83 @@
|
|||||||
|
/**
|
||||||
|
* 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.sqoop.test.db;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Oracle Provider that will connect to remote Oracle server.
|
||||||
|
*
|
||||||
|
* JDBC can be configured via system properties. Default value is server running
|
||||||
|
* on the same box (localhost) that is access via sqoop/sqoop credentials.
|
||||||
|
*/
|
||||||
|
public class OracleProvider extends DatabaseProvider {
|
||||||
|
|
||||||
|
public static final String DRIVER = "oracle.jdbc.OracleDriver";
|
||||||
|
|
||||||
|
private static final String CONNECTION = System.getProperties().getProperty(
|
||||||
|
"sqoop.provider.oracle.jdbc",
|
||||||
|
"jdbc:oracle:thin:@//localhost/xe"
|
||||||
|
);
|
||||||
|
|
||||||
|
private static final String USERNAME = System.getProperties().getProperty(
|
||||||
|
"sqoop.provider.oracle.username",
|
||||||
|
"sqoop"
|
||||||
|
);
|
||||||
|
|
||||||
|
private static final String PASSWORD = System.getProperties().getProperty(
|
||||||
|
"sqoop.provider.oracle.password",
|
||||||
|
"sqoop"
|
||||||
|
);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getConnectionUrl() {
|
||||||
|
return CONNECTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getConnectionUsername() {
|
||||||
|
return USERNAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getConnectionPassword() {
|
||||||
|
return PASSWORD;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeColumnName(String columnName) {
|
||||||
|
return escape(columnName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeTableName(String tableName) {
|
||||||
|
return escape(tableName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeValueString(String value) {
|
||||||
|
return "'" + value + "'";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getJdbcDriver() {
|
||||||
|
return DRIVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String escape(String entity) {
|
||||||
|
return "\"" + entity + "\"";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,83 @@
|
|||||||
|
/**
|
||||||
|
* 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.sqoop.test.db;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Oracle Provider that will connect to remote Oracle server.
|
||||||
|
*
|
||||||
|
* JDBC can be configured via system properties. Default value is server running
|
||||||
|
* on the same box (localhost) that is access via sqoop/sqoop credentials.
|
||||||
|
*/
|
||||||
|
public class SqlServerProvider extends DatabaseProvider {
|
||||||
|
|
||||||
|
public static final String DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
|
||||||
|
|
||||||
|
private static final String CONNECTION = System.getProperties().getProperty(
|
||||||
|
"sqoop.provider.sqlserver.jdbc",
|
||||||
|
"jdbc:sqlserver://localhost"
|
||||||
|
);
|
||||||
|
|
||||||
|
private static final String USERNAME = System.getProperties().getProperty(
|
||||||
|
"sqoop.provider.sqlserver.username",
|
||||||
|
"sqoop"
|
||||||
|
);
|
||||||
|
|
||||||
|
private static final String PASSWORD = System.getProperties().getProperty(
|
||||||
|
"sqoop.provider.sqlserver.password",
|
||||||
|
"sqoop"
|
||||||
|
);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getConnectionUrl() {
|
||||||
|
return CONNECTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getConnectionUsername() {
|
||||||
|
return USERNAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getConnectionPassword() {
|
||||||
|
return PASSWORD;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeColumnName(String columnName) {
|
||||||
|
return escape(columnName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeTableName(String tableName) {
|
||||||
|
return escape(tableName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeValueString(String value) {
|
||||||
|
return "'" + value + "'";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getJdbcDriver() {
|
||||||
|
return DRIVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String escape(String entity) {
|
||||||
|
return "[" + entity + "]";
|
||||||
|
}
|
||||||
|
}
|
@ -95,6 +95,8 @@ public void start() throws Exception {
|
|||||||
jar.contains("avro-") || // Avro
|
jar.contains("avro-") || // Avro
|
||||||
jar.contains("mysql") || // MySQL JDBC driver
|
jar.contains("mysql") || // MySQL JDBC driver
|
||||||
jar.contains("postgre") || // PostgreSQL JDBC driver
|
jar.contains("postgre") || // PostgreSQL JDBC driver
|
||||||
|
jar.contains("oracle") || // Oracle driver
|
||||||
|
jar.contains("sqljdbc") || // Microsoft SQL Server driver
|
||||||
jar.contains("google") // Google libraries (guava, ...)
|
jar.contains("google") // Google libraries (guava, ...)
|
||||||
) {
|
) {
|
||||||
extraClassPath.add(jar);
|
extraClassPath.add(jar);
|
||||||
|
Loading…
Reference in New Issue
Block a user