Vertx:java.sql.SQLSyntaxErrorException:user缺少未找到的权限或对象:ACHAT

时间:2022-10-04 18:06:08

Good morning, I want to connect my vertx app with Sql database by using odbc, but when I run my code a weird error appears : java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: ACHAT

早上好,我想通过使用odbc将我的vertx应用程序与Sql数据库连接,但是当我运行我的代码时出现一个奇怪的错误:java.sql.SQLSyntaxErrorException:user缺少权限或找不到对象:ACHAT

I tried to delete ?shutdown but it stills the same error

我试图删除?关机,但它仍然是同样的错误

Here is my code :

这是我的代码:

 public void start(Future<Void> startFuture){
    String file="/Test1";
    Router router = Router.router(vertx);
       router.route(file).handler(routingContext -> {
        HttpServerResponse response = routingContext.response();
        response.setChunked(true);            
        JsonObject config = new JsonObject()
                  .put("url", "jdbc:hsqldb:mem:odbcName?shutdown=true")   
                  .put("user", "sa")
                  .put("password", "****")
                  .put("driver_class", "org.hsqldb.jdbcDriver")
                  .put("max_pool_size", 30);
        JDBCClient client = JDBCClient.createShared(vertx, config);

        client.getConnection(res -> {
                  if (res.succeeded()) {
                    SQLConnection connection = res.result();
                    connection.query("select id from dbo.achat", res2 -> {
                      if (res2.succeeded()) {
                          System.out.println("oki");
                      }
                      else { System.out.println(res2.cause().toString()); }
                    });
                  } else {
                    System.out.println("Cnx failed !!");
                  }
                });
        routingContext.vertx().setTimer(8000, tid ->  routingContext.response().end());
    });

And for my server :

而对于我的服务器:

     vertx.createHttpServer()
            .requestHandler(router::accept)
            .listen(8085, "localhost", res -> {                    
                if (res.succeeded()){
                    startFuture.complete();    
                }
                else
                    startFuture.fail(res.cause());
            });

1 个解决方案

#1


0  

Connection to HSQLDB from Java apps is via JDBC, not ODBC. Your connection settings use JDBC.

从Java应用程序连接到HSQLDB是通过JDBC而不是ODBC。您的连接设置使用JDBC。

The line below creates a connection to an in-memory database, which is empty when you start:

下面的行创建了与内存数据库的连接,当您启动时,该数据库为空:

 put("url", "jdbc:hsqldb:mem:odbcName?shutdown=true")   

The schema DBO and table ACHATmust be created before you can access it.

架构DBO和表ACHAT必须先创建,然后才能访问它。

#1


0  

Connection to HSQLDB from Java apps is via JDBC, not ODBC. Your connection settings use JDBC.

从Java应用程序连接到HSQLDB是通过JDBC而不是ODBC。您的连接设置使用JDBC。

The line below creates a connection to an in-memory database, which is empty when you start:

下面的行创建了与内存数据库的连接,当您启动时,该数据库为空:

 put("url", "jdbc:hsqldb:mem:odbcName?shutdown=true")   

The schema DBO and table ACHATmust be created before you can access it.

架构DBO和表ACHAT必须先创建,然后才能访问它。