Uploaded image for project: 'Quarkus'
  1. Quarkus
  2. QUARKUS-694

Default database name, throw an exception: 'io.vertx.db2client.DB2Exception'

XMLWordPrintable

    • False
    • False
    • Undefined
    • Hide
      1. Launch Db2 with db2instance set to 'db'

       

      docker run --name db2  -p 50000:50000 --privileged=true -e LICENSE=accept -e DB2INST1_PASSWORD=test -e DB2INSTANCE=db -e AUTOCONFIG=false -e ARCHIVE_LOGS=false -e DBNAME=db ibmcom/db2
      

             2. Set up your app reactive data source

       

       

      ## BD2
      ## Database
      quarkus.datasource.db2.reactive=true
      quarkus.datasource.db2.db-kind=db2
      quarkus.datasource.db2.username=db
      quarkus.datasource.db2.password=test
      quarkus.datasource.db2.reactive.url=vertx-reactive:db2://localhost:50000/db
      

            3. Required Pom dependencies

      <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-reactive-db2-client</artifactId>
      </dependency>
      
      <dependency> 
      <groupId>io.quarkus</groupId> 
      <artifactId>quarkus-jdbc-db2</artifactId> 
      </dependency>
      

       

       

          4. Write down a statement, and you will be able to reproduce it at compile time.
       

      public static Multi<PricingRules> findAll(Pool client) {
      
          return client.query("SELECT * FROM pricingRules").execute().onItem().transformToMulti(PricingRules::fromSet);
      
      }
      

       

       

      Show
      Launch Db2 with db2instance set to 'db'   docker run --name db2 -p 50000:50000 --privileged= true -e LICENSE=accept -e DB2INST1_PASSWORD=test -e DB2INSTANCE=db -e AUTOCONFIG= false -e ARCHIVE_LOGS= false -e DBNAME=db ibmcom/db2        2. Set up your app reactive data source     ## BD2 ## Database quarkus.datasource.db2.reactive= true quarkus.datasource.db2.db-kind=db2 quarkus.datasource.db2.username=db quarkus.datasource.db2.password=test quarkus.datasource.db2.reactive.url=vertx-reactive:db2: //localhost:50000/db       3. Required Pom dependencies <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-reactive-db2-client</artifactId> </dependency> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-jdbc-db2</artifactId> </dependency>         4. Write down a statement, and you will be able to reproduce it at compile time.   public static Multi<PricingRules> findAll(Pool client) { return client.query( "SELECT * FROM pricingRules" ).execute().onItem().transformToMulti(PricingRules::fromSet); }    
    • ---

      data source configuration:

       

      ## BD2
      ## Database
      quarkus.datasource.db2.reactive=true
      quarkus.datasource.db2.db-kind=db2
      quarkus.datasource.db2.username=db
      quarkus.datasource.db2.password=test
      quarkus.datasource.db2.reactive.url=vertx-reactive:db2://localhost:50000/db
      

      Driver Default database name: db

       

      As is not possible to set a default DB for a given data source you must include the dbName in all your statements. If you use the default DB name given by the driver (db) you don't require to add the DB name to your statements, however, Vertx adds the default dbName to your statement in the wrong DB2 format:

      Exception:

      io.vertx.db2client.DB2Exception: The object 'DB.PRICINGRULES' provided is not defined
      

       

       

      Examples:

       select * from DB.PRICINGRULES; -> will not work on DB2
       select * from "DB".PRICINGRULES; -> will work on DB2  
      

       

      Github Ref

              rhn-engineering-tsegismo Thomas Segismont
              rhn-support-pagonzal Pablo Gonzalez Granados (Inactive)
              Martin Ocenas Martin Ocenas
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: