I set up a cluster and bucket on my local machine, I was able to create and retrieve documents using the following methods:
1- Admin page N1QL
2- Scala SDK upsert, insert, and get methods.
There is no problem with the query, indexing, or username/password since they all work with the SDK and admin page.
However, when I tried to use a simple query from Scala project, I did not receive any results. Scala code:
val cluster: Cluster = Cluster.connect("localhost", "Administer", "password")
cluster.query("select * from couchmusic2 limit 10;") match {
case Success(value) => println(value)
case Failure(exception) => println(exception)
}
My log messages: ("retried"" starts from 1 and grows larger) [DEBUG] [2019-07-25 15:31:17,582] [cb-events] [com.couchbase.request] [com.couchbase.request][RequestRetriedEvent][100000µs] Request QueryRequest retried per RetryStrategy {"retried":61,"requestId":1,"timeoutMs":75000,"coreId":1,"completed":false}
Has anyone faced this issue? Is there a way to resolve it?
Thanks!
PS: I am using "scala-client 1.0.0-alpha.4" and “Couchbase-server community 6.0.0” on Windows 10.
There’s a long-standing issue with all the SDKs (this isn’t limited to Scala), in that before you can run a query, you must connect to a bucket. E.g. you add a cluster.bucket(“couchmusic2”) between the connect and the query, it should work. This is so the SDK has a connection it can send the request on.
Couchbase Server 6.5, just released in public beta, will have a new feature that will allow us to address this though. E.g. you won’t need to open the bucket to perform a query.
Hi @graham.pople,
Thanks for the response. I added val bucket = cluster.bucket("couchmusic2") where you suggested and received the following exception ( I looked at the code. method floorMod is defined in the java on my system):
PS: I had used N1QL through Python SDK successfully beforehand.
Thanks.
Exception in thread "main" java.lang.NoSuchMethodError: java.lang.Math.floorMod(JI)I
at com.couchbase.client.core.node.RoundRobinLocator.dispatch(RoundRobinLocator.java:72)
at com.couchbase.client.core.Core.send(Core.java:165)
at com.couchbase.client.core.Core.send(Core.java:150)
at com.couchbase.client.scala.AsyncCluster.query(AsyncCluster.scala:96)
at com.couchbase.client.scala.Cluster.query(Cluster.scala:84)
at <my program>
Hi @surajatreya, I’m happy to see another Scala user.
As I mentioned above, the need to open a bucket first is a long-standing thing that applies to all SDKs, not just Scala. It’s due to a server restriction that is being lifted in Couchbase Server 6.5 - so, when that and the new SDKs are GA, you won’t need to open a bucket to perform a query anymore.