在 Phoenix JDBC 客户端中获取 SQLException

Getting SQLException in Phoenix JDBC client

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

版本信息- Hbase: 0.98.0.2.1.5.0 ;凤凰:phoenix-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.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.execute(CreateTableCompiler.java:186)
    at org.apache.phoenix.jdbc.PhoenixStatement.call(PhoenixStatement.java:300)
    at org.apache.phoenix.jdbc.PhoenixStatement.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.call(ConnectionQueryServicesImpl.java:1891)
    at org.apache.phoenix.query.ConnectionQueryServicesImpl.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。