我使用CQL用cassandra准备了一些表。实际上,我尝试对我的数据应用聚合查询(sum,avg等)。所以,我在java中使用了presto-cassandra。我已按如下方式配置presto:
Config.properties:
coordinator=true
node-scheduler.include-coordinator=true
http-server.http.port=8080
task.max-memory=1GB
discovery-server.enabled=true
discovery.uri= `http://localhost:8080`
JVM.properties:
-server
-Xmx16G
-XX:+UseConcMarkSweepGC
-XX:+ExplicitGCInvokesConcurrent
-XX:+CMSClassUnloadingEnabled
-XX:+AggressiveOpts
-XX:+HeapDumpOnOutOfMemoryError
-XX:OnOutOfMemoryError=kill -9 %p
-XX:PermSize=150M
-XX:MaxPermSize=150M
-XX:ReservedCodeCacheSize=150M
-Xbootclasspath/p:C:/Presto/lib/floatingdecimal-0.1.jar
log.properties:
com.facebook.presto=INFO
node.properties:
node.environment=production
node.id=ffffffff-ffff-ffff-ffff-ffffffffffff
node.data-dir=C:/Presto/data
cassandra.properties:
connector.name=cassandra
cassandra.contact-points=localhost
cassandra.native-protocol-port=9142
cassandra.thrift-port=9160
然后,我一直在尝试连接到presto并通过jdbc运行一些查询,但我一直在收到错误。代码是:
public static void connect() throws ClassNotFoundException, SQLException{
Class.forName("com.facebook.presto.jdbc.PrestoDriver");
PrestoConnection connection = (PrestoConnection) DriverManager.getConnection("jdbc:presto://localhost:8080/cassandra/premierkeys", "test","");
PrestoStatement statement = (PrestoStatement) connection.createStatement();
ResultSet rs = statement.executeQuery("select * from client");
while(rs.next()) {
System.out.println(rs.getString(1));
}
}
public static void main(String[] args) throws ClassNotFoundException, SQLException {
// TODO Auto-generated method stub
connect();
}
此外,maven依赖关系如下所示:
<dependencies>
<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-cassandra</artifactId>
<version>0.72</version>
<type>zip</type>
</dependency>
<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-jdbc</artifactId>
<version>0.72</version>
</dependency>
</dependencies>`
但是当我运行这段代码时,我得到了:
***juil. 02, 2014 11:32:57 AM com.facebook.presto.jdbc.internal.jetty.util.log.JavaUtilLog info
INFOS: Logging initialized @122ms
Exception in thread "main" java.sql.SQLException: Error executing query
at com.facebook.presto.jdbc.PrestoStatement.executeQuery(PrestoStatement.java:54)
at tester_cass.connect(tester_cass.java:19)
at tester_cass.main(tester_cass.java:26)
Caused by: java.lang.IllegalStateException: Response does not contain a JSON value
at com.facebook.presto.jdbc.internal.airlift.http.client.FullJsonResponseHandler$JsonResponse.getValue(FullJsonResponseHandler.java:148)
at com.facebook.presto.jdbc.internal.client.StatementClient.<init>(StatementClient.java:82)
at com.facebook.presto.jdbc.QueryExecutor.startQuery(QueryExecutor.java:60)
at com.facebook.presto.jdbc.PrestoConnection.startQuery(PrestoConnection.java:541)
at com.facebook.presto.jdbc.PrestoStatement.executeQuery(PrestoStatement.java:49)
... 2***
有什么问题?