java 连接kylin,jdbc调用示例

import java.io.IOException;

import java.sql.Connection;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

import java.util.Properties;

import org.apache.kylin.jdbc.Driver;

public class KylinJdbc {

public void connentJdbc() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException{

Driver driver = (Driver) Class.forName("org.apache.kylin.jdbc.Driver").newInstance();

Properties info = new Properties();

info.put("user", "ADMIN");

info.put("password", "KYLIN");

Connection conn = driver.connect("jdbc:kylin://localhost:7070/learn_kylin", info);

Statement state = conn.createStatement();

ResultSet resultSet = state.executeQuery("select * from kylin_sales limit 10 ");

while (resultSet.next()) {

resultSet.getString(1);

System.out.println(resultSet.getString(1));

}

}

public static void main(String[] args) throws IOException, InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException{

KylinJdbc ky = new KylinJdbc();

ky.connentJdbc();

}

}

2019-09-22 00:07:09

共有0条评论!

发表评论