mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
Merge pull request #1760 from yinheli/feature/support-kylin
add kylin support
This commit is contained in:
@@ -490,6 +490,13 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.kylin</groupId>
|
||||
<artifactId>kylin-jdbc</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.quartz-scheduler</groupId>
|
||||
<artifactId>quartz</artifactId>
|
||||
|
||||
@@ -93,6 +93,10 @@ public interface JdbcConstants {
|
||||
public static final String ENTERPRISEDB = "edb";
|
||||
public static final String ENTERPRISEDB_DRIVER = "com.edb.Driver";
|
||||
|
||||
public static final String KYLIN = "kylin";
|
||||
public static final String KYLIN_DRIVER = "org.apache.kylin.jdbc.Driver";
|
||||
|
||||
|
||||
public static final String SQLITE = "sqlite";
|
||||
public static final String SQLITE_DRIVER = "org.sqlite.JDBC";
|
||||
}
|
||||
|
||||
@@ -448,6 +448,8 @@ public final class JdbcUtils implements JdbcConstants {
|
||||
return "org.apache.phoenix.queryserver.client.Driver";
|
||||
} else if (rawUrl.startsWith("jdbc:phoenix://")) {
|
||||
return JdbcConstants.PHOENIX_DRIVER;
|
||||
} else if (rawUrl.startsWith("jdbc:kylin:")) {
|
||||
return JdbcConstants.KYLIN_DRIVER;
|
||||
} else {
|
||||
throw new SQLException("unkow jdbc driver : " + rawUrl);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.alibaba.druid.kylin;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
import com.alibaba.druid.util.JdbcUtils;
|
||||
import org.hamcrest.core.Is;
|
||||
import org.hamcrest.core.IsNull;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* @author yinheli
|
||||
*/
|
||||
public class KylinDriverSupportTest {
|
||||
|
||||
// test config
|
||||
private static final String URL = "jdbc:kylin://172.168.1.111:7070/jlkBigData";
|
||||
private static final String USER_NAME = "ADMIN";
|
||||
private static final String PASSWORD = "KYLIN";
|
||||
private static final String VALIDATION_QUERY = "select 1";
|
||||
|
||||
@Test
|
||||
public void testDriverClassName() throws SQLException {
|
||||
String driverClass = JdbcUtils.getDriverClassName(URL);
|
||||
Assert.assertThat("check get driverClassName", driverClass, Is.is(JdbcConstants.KYLIN_DRIVER));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQuery() throws SQLException {
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
try {
|
||||
dataSource = new DruidDataSource();
|
||||
dataSource.setUrl(URL);
|
||||
dataSource.setUsername(USER_NAME);
|
||||
dataSource.setPassword(PASSWORD);
|
||||
dataSource.setValidationQuery(VALIDATION_QUERY);
|
||||
|
||||
Connection conn = dataSource.getConnection();
|
||||
PreparedStatement state = conn.prepareStatement(VALIDATION_QUERY);
|
||||
ResultSet resultSet = state.executeQuery();
|
||||
Assert.assertThat("check result", resultSet, IsNull.notNullValue());
|
||||
} finally {
|
||||
dataSource.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user