请问:如果要让nutz支持hive,需要做哪方面工作?
参考以下文档直连测试是可以的,想用datasource、dao暂时没头绪,druid原来支持hive,新版本也不支持了。
https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients
感谢:)
请问:如果要让nutz支持hive,需要做哪方面工作?
参考以下文档直连测试是可以的,想用datasource、dao暂时没头绪,druid原来支持hive,新版本也不支持了。
https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients
感谢:)
@wendal 不可以呢,走SimpleDataSource试过,报错,错误信息如下:
Caused by: org.nutz.ioc.IocException: [dao] # FAIL to create Ioc Bean name=[dao]
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:149)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:210)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:239)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:146)
at Test.<clinit>(Test.java:10)
Caused by: java.lang.RuntimeException: Fail to set 'org.nutz.dao.impl.SimpleDataSource@75a287d9'[ org.nutz.dao.impl.SimpleDataSource@75a287d9 ] by setter org.nutz.dao.impl.DaoSupport.'setDataSource()' because [java.sql.SQLException: Method not supported]: Method not supported
at org.nutz.lang.Lang.makeThrow(Lang.java:133)
at org.nutz.lang.inject.InjectBySetter.inject(InjectBySetter.java:44)
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:32)
at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:135)
... 4 more
@laizhiming 这是完整报错信息了?
@wendal 嗯,对的,很简单的测试。
//dao.js
var ioc = {
dataSource : {
type :"org.nutz.dao.impl.SimpleDataSource",
events : {
depose :"close"
},
fields : {
driverClassName : 'org.apache.hive.jdbc.HiveDriver',
jdbcUrl : 'jdbc:hive2://domain1:10000/default',
username : 'hive',
password : 'hive'
}
},
dao : {
type : "org.nutz.dao.impl.NutDao",
fields : {
dataSource : {refer : 'dataSource'}
}
}
}
//Test.java
import org.nutz.dao.Dao;
import org.nutz.ioc.Ioc;
import org.nutz.ioc.impl.NutIoc;
import org.nutz.ioc.loader.json.JsonLoader;
public class Test {
static Ioc ioc = new NutIoc(new JsonLoader("dao.js"));
static Dao dao = ioc.get(Dao.class);
public static void main(String[] args) {
System.out.println(dao.count("test1"));
}
}
先不要用ioc
public static void main(String[] args) {
try {
Class.forName("org.apache.hive.jdbc.HiveDriver");
SimpleDataSource ds = new SimpleDataSource();
ds.setDriverClassName("org.apache.hive.jdbc.HiveDriver");
ds.setJdbcUrl("jdbc:hive2://domain1:10000/default");
ds.setUsername("hive");
ds.setPassword("hive");
Dao dao = new NutDao(ds);
System.out.println(dao.meta());
}
catch (Exception e) {
e.printStackTrace();
}
}
@wendal
错误如下:
org.nutz.dao.DaoException: java.sql.SQLException: Method not supported
at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:128)
at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:81)
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:70)
at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:266)
at org.nutz.dao.impl.DaoSupport.setDataSource(DaoSupport.java:195)
at org.nutz.dao.impl.DaoSupport.setDataSource(DaoSupport.java:181)
at org.nutz.dao.impl.NutDao.<init>(NutDao.java:113)
at Test.main(Test.java:19)
Caused by: java.sql.SQLException: Method not supported
at org.apache.hive.jdbc.HiveDatabaseMetaData.getURL(HiveDatabaseMetaData.java:783)
at org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:202)
at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:147)
at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:114)
... 7 more
@wendal 我反编译了一下org.apache.hive.jdbc.HiveDatabaseMetaData这个类,很多都是Method not supported。
//以下是代码片段
public String getURL() throws SQLException {
throw new SQLException("Method not supported");
}
public String getUserName() throws SQLException {
throw new SQLException("Method not supported");
}
public ResultSet getVersionColumns(String catalog, String schema, String table) throws SQLException
{
throw new SQLException("Method not supported");
}
public boolean insertsAreDetected(int type) throws SQLException {
throw new SQLException("Method not supported");
}
public boolean isCatalogAtStart() throws SQLException {
throw new SQLException("Method not supported");
}
@wendal 好的,我去下载试试看。谢谢
@laizhiming 那是类实例变量吧?
@wendal 我错了,我只下了这一个文件试试看,应该是这个版本没有checkDataSource方法。
已经解决了,可以了,再次谢谢。
@wendal 呃,HiveJdbcExpert拖了两年了。