在这里插入图片描述
在使用Idea的过程中,连接JDBC到Phoenix报错,会抛异常SQLException,一开始是以为SQL的问题,但是在命令行中是key正常运行的,然后排除了好多,最后发现是以为在Phoenix执行的过程中,需要加载hbase-site.xml文件,并且清空下缓存就好了。
解决方案:将虚拟机中Phoenix文件夹里面的hbase-site.xml复制到idea的resource文件夹内,清空缓存重新运行即可。
在这里插入图片描述
hbase-site.xml示例

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
/**
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-->
<configuration>
  <property >
    <name>hbase.tmp.dir</name>
    <value>/export/server/hbase-2.1.0/datas</value>
  </property>
    <property >
    <name>hbase.rootdir</name>
    <value>hdfs://node1:8020/hbase</value>
  </property>
  <property >
    <name>hbase.cluster.distributed</name>
    <value>true</value>
  </property>
  <property>
    <name>hbase.zookeeper.quorum</name>
    <value>node1:2181,node2:2181,node3:2181</value>
  </property>
<!-- 关闭流检查,从2.x开始使用async -->
<property>
    <name>hbase.unsafe.stream.capability.enforce</name>
    <value>false</value>
  </property>
<!-- 支持HBase命名空间映射 -->
<property>
    <name>phoenix.schema.isNamespaceMappingEnabled</name>
    <value>true</value>
</property>
<!-- 支持索引预写日志编码 -->
<property>
  <name>hbase.regionserver.wal.codec</name>
  <value>org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec</value>
</property>
<!-- 配置NS映射 -->
<property>
  <name>phoenix.schema.mapSystemTablesToNamespace</name>
  <value>true</value>
</property>
</configuration>
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐