java.sql.SQLNonTransientConnectionException:Keyspace名称必须由字母数字和下划线组成(解析:'')

时间:2015-06-04 09:40:05

标签: java database eclipse hadoop cassandra

我尝试连接到cassandra数据库并验证用户登录并注册我收到此错误:

Keyspace names must be composed of alphanumerics and underscores (parsed: '')
    at org.apache.cassandra.cql.jdbc.Utils.parseURL(Utils.java:195)
    at org.apache.cassandra.cql.jdbc.CassandraDriver.connect(CassandraDriver.java:85)
    at java.sql.DriverManager.getConnection(DriverManager.java:571)
    at java.sql.DriverManager.getConnection(DriverManager.java:215)
    at com.rest.inndata.services.ConnectCassandra.createConnection(ConnectCassandra.java:56)
    at com.rest.inndata.services.callGoad.checkUser(callGoad.java:1123)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
    at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185)
    at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
    at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1480)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1411)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1360)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1350)
    at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)    
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

2 个答案:

答案 0 :(得分:2)

在创建键空间时删除了所有空格。

答案 1 :(得分:0)

正如您在答案中所述,您的密钥空间名称中不能包含空格:

aploetz@cqlsh:stackoverflow2> CREATE TABLE "testorder by" (id uuid PRIMARY KEY, value text);
InvalidRequest: code=2200 [Invalid query] message=""testorder by" is not a valid column 
    family name (must be alphanumeric character only: [0-9A-Za-z]+)"

虽然它没有明确指出空格,但文档还是这样说:

  

Keyspace名称是32个或更少的字母数字字符和下划线,第一个是字母字符。 Keyspace名称不区分大小写。要使名称区分大小写,请将其用双引号括起来。

老实说,错误消息可以更好地用正则表达式指示有效字符。