线程“主要” com.rethinkdb.gen.exc.ReqlDriverError中的异常:连接超时

时间:2018-09-05 23:15:55

标签: java rethinkdb

我正在使用Gridle,并且正在使用RethinkDB Driver(Java)-2.2.3并在Netbeans(8.2)中运行。我收到此错误代码:

`Exception in thread "main" com.rethinkdb.gen.exc.ReqlDriverError: Connection timed out.
    at com.rethinkdb.net.SocketWrapper.connect(SocketWrapper.java:91)
    at com.rethinkdb.net.Connection.connect(Connection.java:100)
    at com.rethinkdb.net.Connection.reconnect(Connection.java:94)
    at com.rethinkdb.net.Connection.reconnect(Connection.java:83)
    at com.rethinkdb.net.Connection$Builder.connect(Connection.java:422)
    at org.ap.UserInput.grabInput(UserInput.java:24)
    at org.ap.comsci.main(comsci.java:24)
Caused by: java.net.ConnectException: Connection timed out: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
    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.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at com.rethinkdb.net.SocketWrapper.connect(SocketWrapper.java:53)
    ... 6 more`

下面是我正在运行的连接到数据库的代码。抱歉,我似乎无法修复插入内容,因此,如果有人想帮助修复格式,那我就使用hastebin! (https://pastebin.com/XPgPqmc5)。非常感谢其他编辑器将其清理干净! -Java辅助代码

编辑:

UserInput.java

import java.util.Scanner;
import com.rethinkdb.RethinkDB;
import com.rethinkdb.gen.exc.ReqlError;
import com.rethinkdb.gen.exc.ReqlQueryLogicError;
import com.rethinkdb.model.MapObject;
import com.rethinkdb.net.Connection;
import static org.ap.Database.r;

public class UserInput {
         public static Double[] grabInput(){
            Connection conn = r.connection().hostname("Private").port(28015).connect();            
                Scanner scan = new Scanner(System.in);

                //Decide what the scanner will be looking for
                System.out.print("What action will you be completing?: ");
                String action = scan.nextLine();

                //Scans For Action Requests
                    if (action.equals("Login")){
                       //Login Action
                            System.out.print("Username: ");
                            String username = scan.nextLine();
                            System.out.print("Password: ");
                            String password = scan.nextLine();

                      //Login Validation

                      if (r.db("APSCI").table("BankAccounts").filter(row ->
                         row.g("username").eq(username).and(row.g("password").eq(password))).coerceTo("BOOL").run(conn)){
                         System.out.print("Welcome /n (username)");
                      }
                       else {
                           System.out.print("No User Was Found!");
                       }
                    }

                    if (action.equals("Numbers")){
                        //Decide the number of numbers to be used in the array
                        System.out.print("Enter how many numbers you will input: ");
                        Integer numOfNumbers = Integer.parseInt(scan.nextLine());

                        //Create a string array to store the numbers that will be used
                        Double arrayOfNumbers[] = new Double[numOfNumbers];
                        for (int i = 0; i < arrayOfNumbers.length; i++) {
            System.out.print("Enter the number " + (i+1) + " : ");
                arrayOfNumbers[i] = Double.parseDouble(scan.nextLine());
                    }

                        //Now show your numbers
                        System.out.print("My numbers : ");
                        System.out.print(arrayOfNumbers[0]);
                        for (int i = 1;i < arrayOfNumbers.length;i++) {
                            System.out.print(" , " + arrayOfNumbers[i]);
                        }
                        System.out.println();

                        return arrayOfNumbers;


                    }
             return null;
         }
}

0 个答案:

没有答案