简体   繁体   English

尝试使用Java在Arango数据库中创建连接时出现“未经授权”异常

[英]Getting “Unauthorized” exception when trying to create connection in Arango database using Java

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". 我正在尝试使用Java,IDE-Eclipse在Arango数据库中创建连接,但是在执行该程序时,出现了“未经授权”异常。

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 注意:我已经使用用户:root URL- http://127.0.0.1:8529/_db/_system/_admin/aardvark/index.html#logs登录到Arango数据库。

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. 我使用了教程https://www.arangodb.com/tutorials/tutorial-java-old/来编写此程序,并遵循了所有提到的步骤。 Still getting unauthorized exception: 仍然会出现未经授权的异常:
Failed to create database mydb; Unauthorized

You have to set the user and password (default user "root", password empty): 您必须设置用户和密码(默认用户“ root”,密码为空):

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). 另外,我强烈建议您更新到新的Java驱动程序(版本4.1.12)。 Which comes with a new API and a better performance). 其中带有新的API和更好的性能)。 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();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试创建数据库连接时出现异常 - Getting exception while trying to create a database connection 尝试通过Java中的Rally API创建/更新/删除/查询Rally时获取HTTP / 1.1 401未经授权的异常 - Getting HTTP/1.1 401 Unauthorized Exception when trying to Create / Update / Delete / Query Rally through Rally API in java 尝试使用Java在sqlite数据库中创建表时出现空指针异常 - Null pointer exception when trying to create table in sqlite database with Java 尝试使用Hibernate创建MySQL连接时发生异常 - Exception when trying to create MySQL connection with Hibernate Java中使用jconnect连接数据库的异常 - Exception in connection to the database using jconnect in Java 尝试使用FTP将文件上传到服务器时,出现Connection拒绝异常 - getting Connection refused exception when trying to upload a file to the server using FTP 获取 com.xero.api.XeroApiException:尝试创建/更新发票时出现未经授权的错误 - Getting com.xero.api.XeroApiException: Unauthorized error when trying to create/update invoices 尝试使用TrueZip在档案中创建文件时出现EOF异常 - Getting EOF exception when trying to create a file within a an archive using TrueZip 为什么在尝试创建此屏幕(窗口)时出现异常? - Why am I getting an exception when trying to create this Screen(window)? java:尝试将文件上传到FTP时,拒绝连接 - java: getting Connection refused when trying to upload file to FTP
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM