gpt4 book ai didi

hadoop - 在 Phoenix JDBC 客户端中获取 SQLException

转载 作者:可可西里 更新时间:2023-11-01 14:53:01 27 4
gpt4 key购买 nike

我正在编写一个 JDBC 客户端来访问 Phoenix。我尝试了以下用于从表中创建、加载和检索数据的基本代码。我尝试比较版本并寻找问题,但我无法获得此异常的确切原因。这是一个错误,还是您有解释?

版本信息- Hbase:0.98.0.2.1.5.0;凤凰:凤凰-4.0

代码:

public class PheonixTest {

public static void main(String args[]) throws Exception {

String phoenixDriver = "org.apache.phoenix.jdbc.PhoenixDriver";
try {

Class.forName(phoenixDriver);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.exit(1);
}

try {

Statement stmt = null;
ResultSet rset = null;
System.out.println("Connecting ... >");
Connection con = DriverManager
.getConnection("jdbc:phoenix:<zookeeper>");

System.out.println("In Connection Statement -- >");

stmt = con.createStatement();
stmt.executeUpdate("CREATE TABLE IF NOT EXISTS us_population_java2 ( state CHAR(2) NOT NULL, city VARCHAR NOT NULL, population BIGINT CONSTRAINT my_pk PRIMARY KEY (state, city));");
stmt.executeUpdate("upsert into us_population_java values ('NY','New York',8143197)");
stmt.executeUpdate("upsert into us_population_java values ('CA','Los Angeles',3844829)");
stmt.executeUpdate("upsert into us_population_java values ('NY','New York',8143197)");
stmt.executeUpdate("upsert into us_population_java values ('CA','Los Angeles',3844829)");
System.out.println("After Execute Update Statement -- >");
con.commit();

PreparedStatement statement = con
.prepareStatement("select * from us_population_java");

rset = statement.executeQuery();

while (rset.next()) {
System.out.println("In Print Statement -- >");
System.out.println(rset.getString("state"));
}
statement.close();
con.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

异常:

java.sql.SQLException: ERROR 2007 (INT09): Outdated jars. The following servers require an updated phoenix.jar to be put in the classpath of HBase: region=SYSTEM.CATALOG
at org.apache.phoenix.exception.SQLExceptionCode$Factory$1.newException(SQLExceptionCode.java:386)
at org.apache.phoenix.exception.SQLExceptionInfo.buildException(SQLExceptionInfo.java:145)
at org.apache.phoenix.query.ConnectionQueryServicesImpl.checkClientServerCompatibility(ConnectionQueryServicesImpl.java:994)
at org.apache.phoenix.query.ConnectionQueryServicesImpl.ensureTableCreated(ConnectionQueryServicesImpl.java:867)
at org.apache.phoenix.query.ConnectionQueryServicesImpl.createTable(ConnectionQueryServicesImpl.java:1213)
at org.apache.phoenix.query.DelegateConnectionQueryServices.createTable(DelegateConnectionQueryServices.java:112)
at org.apache.phoenix.schema.MetaDataClient.createTableInternal(MetaDataClient.java:1902)
at org.apache.phoenix.schema.MetaDataClient.createTable(MetaDataClient.java:744)
at org.apache.phoenix.compile.CreateTableCompiler$2.execute(CreateTableCompiler.java:186)
at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:300)
at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:292)
at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:290)
at org.apache.phoenix.jdbc.PhoenixStatement.executeUpdate(PhoenixStatement.java:1180)
at org.apache.phoenix.query.ConnectionQueryServicesImpl$12.call(ConnectionQueryServicesImpl.java:1891)
at org.apache.phoenix.query.ConnectionQueryServicesImpl$12.call(ConnectionQueryServicesImpl.java:1860)
at org.apache.phoenix.util.PhoenixContextExecutor.call(PhoenixContextExecutor.java:77)
at org.apache.phoenix.query.ConnectionQueryServicesImpl.init(ConnectionQueryServicesImpl.java:1860)
at org.apache.phoenix.jdbc.PhoenixDriver.getConnectionQueryServices(PhoenixDriver.java:162)
at org.apache.phoenix.jdbc.PhoenixEmbeddedDriver.connect(PhoenixEmbeddedDriver.java:131)
at org.apache.phoenix.jdbc.PhoenixDriver.connect(PhoenixDriver.java:133)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.go.check.PheonixTest.main(PheonixTest.java:29)

最佳答案

看起来您的版本不兼容:http://doc.mapr.com/display/MapR/Using+Apache+Phoenix+on+HBase .

在先决条件中

Apache Phoenix version 4.0 requires HBase 0.98.1 or later.

您可以尝试降级 Phoenix 或升级 Hbase。

关于hadoop - 在 Phoenix JDBC 客户端中获取 SQLException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32764439/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com