Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Cannot connect to Phoenix Query Server using JDBC thin client

avatar
Expert Contributor

Hi,

I could not connect to Phoenix Query Server in HDP2.5 in my Java program using the thin JDBC client. Any advice?

My connection string is: jdbc:phoenix:thin:url=http://localhost:8765. I am using the thin driver: org.apache.phoenix.queryserver.client.Driver.

try {
    Class.forName(driver);
    conn = DriverManager.getConnection(connectionString);
} catch(Exception e) {
    logger.error("Failed connecting to database.", e);
}

I got the below error:

java.lang.RuntimeException: org.apache.phoenix.shaded.com.fasterxml.jackson.core.JsonParseException: Unexpected character ('o' (code 111)): Expected space separating root-level values
 at [Source:
8org.apache.calcite.avatica.proto.Responses$ErrorResponse�
�org.apache.calcite.avatica.com.google.protobuf.InvalidProtocolBufferException: While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either that the input has been truncated or that an embedded message misreported its own length.
	at org.apache.calcite.avatica.com.google.protobuf.InvalidProtocolBufferException.truncatedMessage(InvalidProtocolBufferException.java:70)
	at org.apache.calcite.avatica.com.google.protobuf.CodedInputStream.skipRawBytesSlowPath(CodedInputStream.java:1293)
	at org.apache.calcite.avatica.com.google.protobuf.CodedInputStream.skipRawBytes(CodedInputStream.java:1276)
	at org.apache.calcite.avatica.com.google.protobuf.CodedInputStream.skipField(CodedInputStream.java:197)
	at org.apache.calcite.avatica.com.google.protobuf.CodedInputStream.skipMessage(CodedInputStream.java:273)
	at org.apache.calcite.avatica.com.google.protobuf.CodedInputStream.skipField(CodedInputStream.java:200)
	at org.apache.calcite.avatica.proto.Common$WireMessage.<init>(Common.java:11627)
	at org.apache.calcite.avatica.proto.Common$WireMessage.<init>(Common.java:11595)
	at org.apache.calcite.avatica.proto.Common$WireMessage$1.parsePartialFrom(Common.java:12061)
	at org.apache.calcite.avatica.proto.Common$WireMessage$1.parsePartialFrom(Common.java:12055)
	at org.apache.calcite.avatica.com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:89)
	at org.apache.calcite.avatica.com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:95)
	at org.apache.calcite.avatica.com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:49)
	at org.apache.calcite.avatica.proto.Common$WireMessage.parseFrom(Common.java:11791)
	at org.apache.calcite.avatica.remote.ProtobufTranslationImpl.parseRequest(ProtobufTranslationImpl.java:354)
	at org.apache.calcite.avatica.remote.ProtobufHandler.decode(ProtobufHandler.java:51)
	at org.apache.calcite.avatica.remote.ProtobufHandler.decode(ProtobufHandler.java:31)
	at org.apache.calcite.avatica.remote.AbstractHandler.apply(AbstractHandler.java:94)
	at org.apache.calcite.avatica.remote.ProtobufHandler.apply(ProtobufHandler.java:46)
	at org.apache.calcite.avatica.server.AvaticaProtobufHandler.handle(AvaticaProtobufHandler.java:124)
	at org.apache.phoenix.shaded.org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)
	at org.apache.phoenix.shaded.org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
	at org.apache.phoenix.shaded.org.eclipse.jetty.server.Server.handle(Server.java:499)
	at org.apache.phoenix.shaded.org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
	at org.apache.phoenix.shaded.org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
	at org.apache.phoenix.shaded.org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)
	at org.apache.phoenix.shaded.org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
	at org.apache.phoenix.shaded.org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
	at java.lang.Thread.run(Thread.java:745)
1 ACCEPTED SOLUTION

avatar

can you check that both phoenix query server and phoenix client versions are same.

View solution in original post

6 REPLIES 6

avatar

can you check that both phoenix query server and phoenix client versions are same.

avatar
Expert Contributor

Both shipped from HDP2.5, should be the same.

avatar

can you try adding serialization=PROTOBUF in your connection string. There seems to be property "phoenix.queryserver.serialization mismatch at client and server.

 jdbc:phoenix:thin:url=http://localhost:8765;serialization=PROTOBUF

avatar
Super Guru

Yup! This is it. The client is trying to use JSON but the server is configured to use PROTOBUF.

If you want to use JSON (which I do not recommend), set phoenix.queryserver.serialization=JSON in hbase-site.xml and restart the Phoenix Query Server.

avatar
Expert Contributor

Thanks, @Ankit Singhal

This solved the issue.

avatar

it's great that it works for you..so can you accept the answer now so that it will be helpful for other users.