最近在学习hbase时用java连接数据库出现以下错误,配置文件和hbase启动均没有问题
控制台出现以下错误
Exception in thread "main" java.lang.ExceptionInInitializerError at org.apache.hadoop.util.StringUtils.<clinit>
Caused by: java.lang.StringIndexOutOfBoundsException: begin 0, end 3, length3
解决方案
最后发现是window的jdk版本过高,我的是jdk12,和eclispe的jdk版本出现冲突,hbase使用版本是jdk1.8,虽然eclispe调的是1.8,但仍然出现错误。于是,我把版本切换到1.8,问题成功解决。
还有
Configuration conf = HBaseConfiguration.create();
conf.set("hbase.zookeeper.quorum", "master:2181,slave1:2181,slave2:2181");
当没有设置好zookeeper的地址和端口,会出现一直连接等待的情况,设置zookeeper集群的地址C:\Windows\System32\drivers\etc\hosts,还有hbase-site.xml中的zookeeper地址
<configuration>
<!-- 指定hbase在HDFS上存储的路径 -->
<property>
<name>hbase.rootdir</name>
<