Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

Upgrade to prestosql v324 #20

Merged
merged 3 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.prestosql</groupId>
<artifactId>presto-root</artifactId>
<version>300</version>
<version>324</version>
</parent>

<artifactId>presto-db2</artifactId>
Expand Down Expand Up @@ -61,7 +61,6 @@
<dependency>
<groupId>io.airlift</groupId>
<artifactId>units</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
Expand All @@ -70,6 +69,12 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.openjdk.jol</groupId>
<artifactId>jol-core</artifactId>
<scope>provided</scope>
</dependency>

<!-- for testing -->
<dependency>
<groupId>org.testng</groupId>
Expand Down
25 changes: 7 additions & 18 deletions src/main/java/io/prestosql/plugin/db2/DB2Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,33 @@
import com.ibm.db2.jcc.DB2Driver;
import io.prestosql.plugin.jdbc.BaseJdbcClient;
import io.prestosql.plugin.jdbc.BaseJdbcConfig;
import io.prestosql.plugin.jdbc.DriverConnectionFactory;
import io.prestosql.plugin.jdbc.JdbcConnectorId;
import io.prestosql.plugin.jdbc.ConnectionFactory;
import io.prestosql.plugin.jdbc.JdbcIdentity;
import io.prestosql.plugin.jdbc.StatsCollecting;
import io.prestosql.plugin.jdbc.JdbcSplit;

import javax.inject.Inject;

import java.sql.Connection;
import java.sql.Driver;
import java.sql.SQLException;
import java.util.Properties;

public class DB2Client
extends BaseJdbcClient
{
@Inject
public DB2Client(JdbcConnectorId connectorId, BaseJdbcConfig config) throws SQLException
public DB2Client(BaseJdbcConfig config, @StatsCollecting ConnectionFactory connectionFactory) throws SQLException
{
super(connectorId, config, "", createDriverConnectionFactory(new DB2Driver(), config));
super(config, "", connectionFactory);

// http://stackoverflow.com/questions/16910791/getting-error-code-4220-with-null-sql-state
System.setProperty("db2.jcc.charsetDecoderEncoder", "3");
}

private static DriverConnectionFactory createDriverConnectionFactory(Driver driver, BaseJdbcConfig config)
{
Properties connectionProperties = DriverConnectionFactory.basicConnectionProperties(config);
// https://www-01.ibm.com/support/knowledgecenter/ssw_ibm_i_72/rzaha/conprop.htm
// block size (aka fetch size), default 32
connectionProperties.setProperty("block size", "512");

return new DriverConnectionFactory(driver, config.getConnectionUrl(), connectionProperties);
}

@Override
public Connection getConnection(JdbcSplit split)
public Connection getConnection(JdbcIdentity identity, JdbcSplit split)
throws SQLException
{
Connection connection = super.getConnection(split);
Connection connection = super.getConnection(identity, split);
try {
// TRANSACTION_READ_UNCOMMITTED = Uncommitted read
// http://www.ibm.com/developerworks/data/library/techarticle/dm-0509schuetz/
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/io/prestosql/plugin/db2/DB2ClientModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,22 @@
*/
package io.prestosql.plugin.db2;

import com.ibm.db2.jcc.DB2Driver;
import com.google.inject.Binder;
import com.google.inject.Module;
import com.google.inject.Provides;
import com.google.inject.Scopes;
import com.google.inject.Singleton;
import io.prestosql.plugin.jdbc.BaseJdbcConfig;
import io.prestosql.plugin.jdbc.ConnectionFactory;
import io.prestosql.plugin.jdbc.DriverConnectionFactory;
import io.prestosql.plugin.jdbc.JdbcClient;
import io.prestosql.plugin.jdbc.credential.CredentialProvider;

import static io.airlift.configuration.ConfigBinder.configBinder;

import java.util.Properties;

public class DB2ClientModule
implements Module
{
Expand All @@ -30,4 +38,16 @@ public void configure(Binder binder)
binder.bind(JdbcClient.class).to(DB2Client.class).in(Scopes.SINGLETON);
configBinder(binder).bindConfig(BaseJdbcConfig.class);
}

@Provides
@Singleton
public static ConnectionFactory getConnectionFactory(BaseJdbcConfig config, CredentialProvider credentialProvider)
{
Properties connectionProperties = new Properties();
// https://www-01.ibm.com/support/knowledgecenter/ssw_ibm_i_72/rzaha/conprop.htm
// block size (aka fetch size), default 32
connectionProperties.setProperty("block size", "512");

return new DriverConnectionFactory(new DB2Driver(), config.getConnectionUrl(), connectionProperties, credentialProvider);
}
}