Skip to content

Commit

Permalink
Remove dependencies on Jena and HttpClient (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnsmith committed Apr 5, 2017
1 parent 3ecb29c commit 9f48cc6
Show file tree
Hide file tree
Showing 148 changed files with 12,779 additions and 8,841 deletions.
14 changes: 11 additions & 3 deletions .editorconfig
Expand Up @@ -2,9 +2,17 @@

root = true

[*.{java,md,rq,ttl,xml,yml}]
[*]
insert_final_newline = true
end_of_line = lf

[*.{java,json,md,rj,rq,srj,ttl,xml,yml}]
charset = utf-8
indent_style = space
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf

[*.{xml}]
indent_size = 4

[*.{json,rj,rq,srj}]
indent_size = 2
4 changes: 2 additions & 2 deletions NOTICE.txt
@@ -1,10 +1,10 @@
dw-jdbc
Copyright 2016 data.world, Inc.
Copyright 2017 data.world, Inc.

Licensed 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. This product includes software developed at
data.world, Inc.(http://www.data.world/).
data.world, Inc.(http://www.data.world/).
15 changes: 9 additions & 6 deletions README.md
Expand Up @@ -2,20 +2,20 @@

dw-jdbc is a JDBC driver for connecting to datasets hosted on data.world.
It can be used to provide read-only access to any dataset provided by data.world
from any JVM language. dw-jdbc supports query access both in dwSQL
from any JVM language. dw-jdbc supports query access both in dwSQL
(data.world's SQL dialect) and in SPARQL 1.1, the native query language
for semantic web data sources.


## JDBC URLs

JDBC connects to data source based on a provided JDBC url. data.world
JDBC connects to data source based on a provided JDBC url. data.world
JDBC urls have the form

jdbc:data:world:[language]:[user id]:[dataset id]

where [language] is either "sql" or "sparql",[user id] is the data.world
id of the dataset owner, and [dataset id] is the data.world identifier for
id of the dataset owner, and [dataset id] is the data.world identifier for
the dataset.

## Sample code (Java 8)
Expand All @@ -33,7 +33,7 @@ final String URL = "jdbc:data:world:sql:dave:lahman-sabremetrics-dataset";


try (final Connection connection = // get a connection to the database, which will automatically be closed when done
DriverManager.getConnection(URL, "<your user name>", "<your API token>");
DriverManager.getConnection(URL, "<your user name>", "<your API token>");
final PreparedStatement statement = // get a connection to the database, which will automatically be closed when done
connection.prepareStatement(QUERY)) {
statement.setString(1, "alexape01"); //bind a query parameter
Expand All @@ -52,6 +52,9 @@ try (final Connection connection = // get a connection to the database, which
System.out.print(columnValue);
}
System.out.println("");

// Note: when calling ResultSet.getObject() prefer the version that takes an explicit Class argument:
// Integer n = resultSet.getObject(param, Integer.class);
}
}
}
Expand All @@ -65,7 +68,7 @@ If using Maven, you can use dw-jdbc by just including the following in your pom.
<dependency>
<groupId>world.data</groupId>
<artifactId>dw-jdbc</artifactId>
<version>0.1.1</version>
<version>0.4</version>
</dependency>
```

Expand All @@ -77,7 +80,7 @@ provide dw-jdbc bundled with all its dependencies under the following:
<groupId>world.data</groupId>
<artifactId>dw-jdbc</artifactId>
<classifier>shaded</classifier>
<version>0.2</version>
<version>0.4</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion mvn-release.sh
@@ -1,4 +1,4 @@
#Copyright 2016 data.world, Inc.
#Copyright 2017 data.world, Inc.
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the
Expand Down
115 changes: 53 additions & 62 deletions pom.xml
Expand Up @@ -6,11 +6,11 @@
<parent>
<groupId>world.data</groupId>
<artifactId>datadotworld-parent</artifactId>
<version>0.2.2</version>
<version>0.2.3</version>
</parent>

<artifactId>dw-jdbc</artifactId>
<version>0.3-SNAPSHOT</version>
<version>0.4-SNAPSHOT</version>

<name>dw-jdbc</name>

Expand All @@ -31,68 +31,35 @@

<properties>
<encoding>UTF-8</encoding>
<jena.version>3.2.0</jena.version>
<jacoco.minimum-coverage>0.75</jacoco.minimum-coverage>
</properties>

<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.4</version>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-arq</artifactId>
<version>${jena.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-base</artifactId>
<version>${jena.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-core</artifactId>
<version>${jena.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-iri</artifactId>
<version>${jena.version}</version>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.1</version>
</dependency>

<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-jdbc-core</artifactId>
<version>${jena.version}</version>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.14</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.20</version>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down Expand Up @@ -134,12 +101,18 @@
</execution>
</executions>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
</transformers>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>shaded</shadedClassifierName>
<createDependencyReducedPom>false</createDependencyReducedPom>
<relocations>
<relocation>
<pattern>com.fasterxml.jackson</pattern>
<shadedPattern>world.data.jdbc.internal.jackson</shadedPattern>
</relocation>
</relocations>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -197,7 +170,7 @@
<exclude>pom.xml</exclude>
<exclude>settings.xml</exclude>
<exclude>**/META-INF/services/*</exclude>
<exclude>**/test/resources/*</exclude>
<exclude>**/test/resources/**</exclude>
</excludes>
</configuration>
<executions>
Expand All @@ -222,7 +195,20 @@
<rules>
<bannedDependencies>
<excludes>
<exclude>commons-logging</exclude>
<!-- The jdbc driver should use java.util.Logging, not a 3rd-party logging library -->
<exclude>commons-logging:commons-logging</exclude>
<exclude>log4j:log4j</exclude>
<exclude>org.slf4j:slf4j-api</exclude>

<!-- These are common dependencies that might be picked up via transitive dependencies -->
<!-- Think hard before allowing any of these dependencies, are they *really* necessary? -->
<!-- The more dependencies we have, the more likely users are to encounter conflicts! -->
<exclude>com.fasterxml.jackson.core:jackson-databind</exclude>
<exclude>com.google.guava:guava</exclude>
<exclude>commons-io:commons-io:*:*:compile</exclude>
<exclude>org.apache.commons</exclude>
<exclude>org.apache.httpcomponents</exclude>
<exclude>org.apache.jena</exclude>
</excludes>
</bannedDependencies>
</rules>
Expand All @@ -235,15 +221,20 @@
</goals>
<configuration>
<rules>
<compound implementation="com.github.ferstl.maven.pomenforcers.CompoundPedanticEnforcer">
<compound
implementation="com.github.ferstl.maven.pomenforcers.CompoundPedanticEnforcer">
<enforcers>
POM_SECTION_ORDER,MODULE_ORDER,DEPENDENCY_MANAGEMENT_ORDER,DEPENDENCY_ORDER,DEPENDENCY_SCOPE,PLUGIN_MANAGEMENT_ORDER
</enforcers>
<dependenciesGroupIdPriorities>${project.groupId},world.data</dependenciesGroupIdPriorities>
<dependenciesGroupIdPriorities>${project.groupId},world.data
</dependenciesGroupIdPriorities>
<dependenciesScopePriorities>compile,runtime,provided</dependenciesScopePriorities>
<dependencyManagementGroupIdPriorities>${project.groupId},world.data</dependencyManagementGroupIdPriorities>
<dependencyManagementScopePriorities>import,compile,runtime,provided</dependencyManagementScopePriorities>
<pluginManagementGroupIdPriorities>${project.groupId},world.data</pluginManagementGroupIdPriorities>
<dependencyManagementGroupIdPriorities>${project.groupId},world.data
</dependencyManagementGroupIdPriorities>
<dependencyManagementScopePriorities>import,compile,runtime,provided
</dependencyManagementScopePriorities>
<pluginManagementGroupIdPriorities>${project.groupId},world.data
</pluginManagementGroupIdPriorities>
</compound>
</rules>
<fail>true</fail>
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/world/data/jdbc/DataWorldCallableStatement.java
@@ -0,0 +1,28 @@
/*
* dw-jdbc
* Copyright 2017 data.world, Inc.
* Licensed 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.
*
* This product includes software developed at data.world, Inc.(http://www.data.world/).
*/
package world.data.jdbc;

import java.sql.CallableStatement;

/**
* Extends {@link CallableStatement} with data.world-specific extensions.
*/
public interface DataWorldCallableStatement extends CallableStatement, DataWorldPreparedStatement {
}
70 changes: 70 additions & 0 deletions src/main/java/world/data/jdbc/DataWorldConnection.java
@@ -0,0 +1,70 @@
/*
* dw-jdbc
* Copyright 2017 data.world, Inc.
* Licensed 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.
*
* This product includes software developed at data.world, Inc.(http://www.data.world/).
*/
package world.data.jdbc;

import java.sql.Connection;
import java.sql.SQLException;

/**
* Extends {@link Connection} with data.world-specific extensions.
*/
public interface DataWorldConnection extends Connection {

/**
* Gets the JDBC compatibility level that is in use, see
* {@link JdbcCompatibility} for explanations
* <p>
* By default this is set at the connection level and inherited, however you
* may call {@link #setJdbcCompatibilityLevel(JdbcCompatibility)} to set the compatibility
* level for this statement. This allows you to change the compatibility
* level on a per-query basis if so desired.
* </p>
*
* @return Compatibility level
*/
JdbcCompatibility getJdbcCompatibilityLevel() throws SQLException;

/**
* Sets the JDBC compatibility level that is in use, see
* {@link JdbcCompatibility} for explanations.
* <p>
* By default this is set at the connection level and inherited, however you
* may call the {@code setJdbcCompatibilityLevel} method to set the compatibility
* level for this statement. This allows you to change the compatibility
* level on a per-query basis if so desired.
* </p>
* <p>
* Changing the level may not effect existing open objects, behaviour in
* this case will be implementation specific.
* </p>
*
* @param compatibilityLevel Compatibility level
*/
void setJdbcCompatibilityLevel(JdbcCompatibility compatibilityLevel) throws SQLException;

@Override
DataWorldCallableStatement prepareCall(String query) throws SQLException;

@Override
DataWorldPreparedStatement prepareStatement(String query) throws SQLException;

@Override
DataWorldStatement createStatement() throws SQLException;
}

0 comments on commit 9f48cc6

Please sign in to comment.