parent
f7137db881
commit
21e3482bca
@ -0,0 +1,30 @@
|
|||||||
|
package UnitTest;
|
||||||
|
|
||||||
|
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
||||||
|
import com.jfinal.plugin.activerecord.Db;
|
||||||
|
import com.jfinal.plugin.activerecord.Record;
|
||||||
|
import com.jfinal.plugin.activerecord.dialect.AnsiSqlDialect;
|
||||||
|
import com.jfinal.plugin.druid.DruidPlugin;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ClickhouseUtils {
|
||||||
|
|
||||||
|
public static void main(String[] args) throws SQLException {
|
||||||
|
String jdbcUrl = "jdbc:clickhouse://10.10.14.225:8123/db_test";// url路径
|
||||||
|
String user = "default";// 账号
|
||||||
|
String password = "DsideaL147258369";// 密码
|
||||||
|
DruidPlugin hp = new DruidPlugin(jdbcUrl, user, password,"com.clickhouse.jdbc.ClickHouseDriver");
|
||||||
|
hp.start();
|
||||||
|
|
||||||
|
// 配置ActiveRecord插件
|
||||||
|
ActiveRecordPlugin arp = new ActiveRecordPlugin(hp);
|
||||||
|
arp.setDialect(new AnsiSqlDialect());
|
||||||
|
arp.start();
|
||||||
|
|
||||||
|
String sql="select substr(class_name,1,4) as title,count(1) as cnt from db_test.t_base_class group by substr(class_name,1,4) order by cnt desc;";
|
||||||
|
List<Record> list= Db.find(sql);
|
||||||
|
System.out.println(list);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue