Exception in thread "main" java.sql.SQLException: ERROR 201 (22000): Illegal data.
at org.apache.phoenix.exception.SQLExceptionCode$Factory$1.newException(SQLExceptionCode.java:309)
at org.apache.phoenix.exception.SQLExceptionInfo.buildException(SQLExceptionInfo.java:133)
at org.apache.phoenix.expression.LiteralExpression.newConstant(LiteralExpression.java:178)
at org.apache.phoenix.expression.ComparisonExpression.create(ComparisonExpression.java:168)
at org.apache.phoenix.compile.ExpressionCompiler.visitLeave(ExpressionCompiler.java:191)
at org.apache.phoenix.compile.ExpressionCompiler.visitLeave(ExpressionCompiler.java:106)
at org.apache.phoenix.parse.ComparisonParseNode.accept(ComparisonParseNode.java:45)
at org.apache.phoenix.compile.WhereCompiler.compile(WhereCompiler.java:92)
at org.apache.phoenix.compile.QueryCompiler.compileSingleQuery(QueryCompiler.java:260)
at org.apache.phoenix.compile.QueryCompiler.compile(QueryCompiler.java:128)
at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:264)
at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:253)
at org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:199)
at org.apache.phoenix.jdbc.PhoenixPreparedStatement.executeQuery(PhoenixPreparedStatement.java:157)
at com.zte.esb.nosql.dao.hbase.HBaseDaoImpl.executeQuery(HBaseDaoImpl.java:43)
at com.zte.esb.nosql.test.Test_Phoenix.main(Test_Phoenix.java:29)
Caused by: org.apache.phoenix.schema.IllegalDataException: CHAR types may only contain single byte characters (中)
at <span style="color:#ff0000;">org.apache.phoenix.schema.PDataType$2.toBytes(PDataType.java:204)</span>
at org.apache.phoenix.schema.PDataType.toBytes(PDataType.java:6748)
at org.apache.phoenix.expression.LiteralExpression.newConstant(LiteralExpression.java:160)
... 13 more
查看抛出异常源码位置
@Override
public byte[] toBytes(Object object) {
if (object == null) {
throw new ConstraintViolationException(this + " may not be null");
}
byte[] b = VARCHAR.toBytes(object);
if (b.length != ((String) object).length()) {//当看到这,有点蒙了,中文获取的字节长度怎么才能等于本身leng?
throw new IllegalDataException("CHAR types may only contain single byte characters (" + object + ")");
}
return b;
}