0
cqlクエリを実行して1つのクエリでスキーマとテーブルを作成するJava datastaxドライバを実行しています。また、以下のようにEOF例外を受け取ります。が見つかりません。EOFセッションがdatastaxドライバを使用してcqlクエリを実行します。
session.execute("CREATE KEYSPACE testkeyspace WITH REPLICATION = { 'class' : 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '3' } AND DURABLE_WRITES = true;"+
"CREATE TABLE testkeyspace.users (" +
" name text," +
" birth_year int," +
" gender text," +
" PRIMARY KEY (name)" +
") WITH read_repair_chance = 0.0" +
" AND dclocal_read_repair_chance = 0.1" +
" AND gc_grace_seconds = 864000" +
" AND bloom_filter_fp_chance = 0.01" +
" AND caching = { 'keys' : 'ALL', 'rows_per_partition' : 'NONE' }" +
" AND comment = ''" +
" AND compaction = { 'class' : 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy' }" +
" AND compression = { 'sstable_compression' : 'org.apache.cassandra.io.compress.LZ4Compressor' }" +
" AND default_time_to_live = 0" +
" AND speculative_retry = '99.0PERCENTILE'" +
" AND min_index_interval = 128" +
" AND max_index_interval = 2048;");
例外トレース
Exception in thread "main" com.datastax.driver.core.exceptions.SyntaxError: line 1:159 missing EOF at 'CREATE' (...} AND DURABLE_WRITES = true;[CREATE] TABLE...)
at com.datastax.driver.core.exceptions.SyntaxError.copy(SyntaxError.java:58)
at com.datastax.driver.core.exceptions.SyntaxError.copy(SyntaxError.java:24)
at com.datastax.driver.core.DriverThrowables.propagateCause(DriverThrowables.java:37)
at com.datastax.driver.core.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:245)
at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:63)
at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:39)
at com.example.helloworld.HelloWorld.main(HelloWorld.java:58)
Caused by: com.datastax.driver.core.exceptions.SyntaxError: line 1:159 missing EOF at 'CREATE' (...} AND DURABLE_WRITES = true;[CREATE] TABLE...)
at com.datastax.driver.core.Responses$Error.asException(Responses.java:132)
at com.datastax.driver.core.DefaultResultSetFuture.onSet(DefaultResultSetFuture.java:179)
at com.datastax.driver.core.RequestHandler.setFinalResult(RequestHandler.java:184)
at com.datastax.driver.core.RequestHandler.access$2500(RequestHandler.java:43)
at com.datastax.driver.core.RequestHandler$SpeculativeExecution.setFinalResult(RequestHandler.java:798)
at com.datastax.driver.core.RequestHandler$SpeculativeExecution.onSet(RequestHandler.java:617)
at com.datastax.driver.core.Connection$Dispatcher.channelRead0(Connection.java:1005)
at com.datastax.driver.core.Connection$Dispatcher.channelRead0(Connection.java:928)
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:266)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:276)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:263)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
at java.lang.Thread.run(Thread.java:745)
回避策はありますか? 1回の呼び出しですべてのステートメントを実行するには? –
私は自分の答えを広げました。 2つのDDL文を連続して実行することについての懸念は何ですか? –
バックアップフェーズ中にすべてのキースペースのスキーマを1つのファイルにダンプするので、ファイル内の各ステートメントを解析して実行するのではなく、ファイル内のすべてのDDLステートメントを実行して(キースペースと列ファミリを作成する)連続的に。 –