Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-18789

Not able to connect to Query Service via a simple jdbc call

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Test Blocker
    • 4.5.0
    • 4.5.0
    • query
    • None
    • Untriaged
    • Unknown

    Description

      Steps to reproduce:

      Run the following program with build 1854

      import java.sql.Connection;
      import java.sql.DriverManager;
      import java.sql.ResultSet;
      import java.sql.Statement;

      /*

      • This example shows
      • a) How to run a simple SELECT statement using the Couchbase JDBC driver.
      • b) How to retrieve scalar field values from the rows.
        */
        public class SimpleSelects {
        static String ConnectionURL = "jdbc:couchbase://172.23.123.107:8093";

      public static void main(String[] args) throws Exception {
      Connection con = DriverManager.getConnection(ConnectionURL);
      Statement stmt = con.createStatement();

      ResultSet rs = stmt
      .executeQuery("select name, abv, (abv > 5) as strong from `beer-sample` where type = 'beer' limit 10");

      /*ResultSet rs = stmt
      .executeQuery("select count as MYCOUNT from `mobile` limit 10");*/
      System.out.println("TEN BEERS");
      while (rs.next())

      { //String name = rs.getString("name"); double abv = rs.getDouble("MYCOUNT"); //boolean strong = rs.getBoolean("strong"); //System.out.println("name: " + name + ", abv: " + abv + ", strong: " + strong); System.out.println("MYCOUNT: " + abv); }

      System.out.println();

      /* rs = stmt.executeQuery("select category, count as num from `beer-sample` where type = 'beer' group by category");
      System.out.println("BEER CATEGORIES");
      while (rs.next())

      { System.out.println(rs.getString("category") + ": " + rs.getInt("num")); }

      */
      }
      }

      Here is the error I am getting

      LF4J: Class path contains multiple SLF4J bindings.
      SLF4J: Found binding in [jar:file:/Users/raju/Downloads/test/jdbc-cb/target/jdbc-cb-0.4.1-SNAPSHOT.jar!/org/slf4j/impl/StaticLoggerBinder.class]
      SLF4J: Found binding in [jar:file:/Users/raju/Downloads/slf4j-1.7.13/slf4j-jdk14-1.7.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
      SLF4J: Found binding in [jar:file:/Users/raju/Downloads/slf4j-1.7.13/slf4j-simple-1.7.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
      SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
      SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
      11:24:54.979 [main] INFO com.couchbase.CBDriver - Constructor called
      11:24:54.982 [main] INFO com.couchbase.CBDriver - Constructor called
      11:24:55.359 [main] ERROR com.couchbase.jdbc.core.ProtocolImpl - Error executing query [select name, abv, (abv > 5) as strong from `beer-sample` where type = 'beer' limit 10] Connect to 127.0.0.1:8093 [/127.0.0.1] failed: Connection refused
      Exception in thread "main" java.sql.SQLException: Error executing update
      at com.couchbase.jdbc.core.ProtocolImpl.query(ProtocolImpl.java:348)
      at com.couchbase.CBStatement.executeQuery(CBStatement.java:75)
      at SimpleSelects.main(SimpleSelects.java:20)
      Caused by: java.net.ConnectException: Connection refused
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
      at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
      at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
      at java.net.Socket.connect(Socket.java:589)
      at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:74)
      at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134)
      at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
      at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
      at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
      at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
      at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
      at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
      at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
      at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
      at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
      at com.couchbase.jdbc.core.ProtocolImpl.query(ProtocolImpl.java:330)

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              korrigan.clark Korrigan Clark (Inactive)
              raju Raju Suravarjjala
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty