1

I am trying to create a connection in Arango databse using Java , IDE- Eclipse but while executing the program I am getting the exception "Unauthorized".

Note: I have logged in to Arango Database with user :root URL- http://127.0.0.1:8529/_db/_system/_admin/aardvark/index.html#logs

Program in Eclipse

    import static com.arangodb.*;
    public class FirstProject {

        public static void main(String[] args) {
            ArangoConfigure configure = new ArangoConfigure();
            configure.init();
            ArangoDriver arangoDriver = new ArangoDriver(configure);
            String dbName = "mydb";
            try { 
              arangoDriver.createDatabase(dbName); 
              System.out.println("Database created: " + dbName);
            } catch (Exception e) { 
              System.out.println("Failed to create database " + dbName + "; " + e.getMessage()); 
            }        
        }
    }

I have used the tutorial https://www.arangodb.com/tutorials/tutorial-java-old/ to write this program and followed all the steps mentioned. Still getting unauthorized exception:
Failed to create database mydb; Unauthorized

1 Answer 1

2

You have to set the user and password (default user "root", password empty):

ArangoConfigure configure = new ArangoConfigure();
configure.init();
configure.setUser("root");
configure.setPassword("");
ArangoDriver arangoDriver = new ArangoDriver(configure);

In addition I highly suggest you to update to the new java driver (version 4.1.12). Which comes with a new API and a better performance). There is also a tutorial for it (see here).

The required code for your problem in this version would be:

ArangoDB arangoDB = ArangoDB.Builder().user("root").password("").build();
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the solution.Worked for me after providing the password in the setPassword

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.