Is there a way to add a specific Role to when connecting to an Oracle DB via JBDC











up vote
1
down vote

favorite












I'm trying to use Java to connect to an Oracle DB with ASM. I want to query ASM specific metrics. However, I can only access it with the "sysasm" role.



Here are a couple of examples of my URLs:



connectionUrl: "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=*host*)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=+ASM)(INSTANCE_NAME=+ASM1)(UR=A)))"

connectionUrl: "jdbc:oracle:thin:"sys/*password* as sysasm"@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=host)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=+ASM)(INSTANCE_NAME=+ASM1)(UR=A)))"

connectionUrl: "jdbc:oracle:thin:@*host*:1521:+ASM1"


I took a look in the docs but I couldn't see anything about roles and the connection string.










share|improve this question




























    up vote
    1
    down vote

    favorite












    I'm trying to use Java to connect to an Oracle DB with ASM. I want to query ASM specific metrics. However, I can only access it with the "sysasm" role.



    Here are a couple of examples of my URLs:



    connectionUrl: "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=*host*)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=+ASM)(INSTANCE_NAME=+ASM1)(UR=A)))"

    connectionUrl: "jdbc:oracle:thin:"sys/*password* as sysasm"@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=host)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=+ASM)(INSTANCE_NAME=+ASM1)(UR=A)))"

    connectionUrl: "jdbc:oracle:thin:@*host*:1521:+ASM1"


    I took a look in the docs but I couldn't see anything about roles and the connection string.










    share|improve this question


























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I'm trying to use Java to connect to an Oracle DB with ASM. I want to query ASM specific metrics. However, I can only access it with the "sysasm" role.



      Here are a couple of examples of my URLs:



      connectionUrl: "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=*host*)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=+ASM)(INSTANCE_NAME=+ASM1)(UR=A)))"

      connectionUrl: "jdbc:oracle:thin:"sys/*password* as sysasm"@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=host)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=+ASM)(INSTANCE_NAME=+ASM1)(UR=A)))"

      connectionUrl: "jdbc:oracle:thin:@*host*:1521:+ASM1"


      I took a look in the docs but I couldn't see anything about roles and the connection string.










      share|improve this question















      I'm trying to use Java to connect to an Oracle DB with ASM. I want to query ASM specific metrics. However, I can only access it with the "sysasm" role.



      Here are a couple of examples of my URLs:



      connectionUrl: "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=*host*)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=+ASM)(INSTANCE_NAME=+ASM1)(UR=A)))"

      connectionUrl: "jdbc:oracle:thin:"sys/*password* as sysasm"@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=host)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=+ASM)(INSTANCE_NAME=+ASM1)(UR=A)))"

      connectionUrl: "jdbc:oracle:thin:@*host*:1521:+ASM1"


      I took a look in the docs but I couldn't see anything about roles and the connection string.







      oracle






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 at 7:01









      Dmitry Demin

      786139




      786139










      asked Nov 12 at 18:31









      Ryan Plummer

      83




      83
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote













          The "as sysasm" should be applied to the user:



          "jdbc:oracle:thin:"sys as sysasm/*password*"@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=host)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=+ASM)(INSTANCE_NAME=+ASM1)(UR=A)))"





          share|improve this answer




























            up vote
            0
            down vote













                public void connect() throws Exception {
            String connectString;
            Class.forName("oracle.jdbc.driver.OracleDriver");

            connectString = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=*host*)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=+ASM)(INSTANCE_NAME=+ASM1)(UR=A)))"

            System.out.println("Before DriverManager.getConnection");
            try {
            connection = DriverManager.getConnection(connectString, "sys as sysasm", "password_for_sys");
            System.out.println("Connection established");

            connection.setAutoCommit(false);
            } catch (Exception e) {
            // TODO: handle exception
            System.out.println("Exception inside connect(): " + e);
            e.printStackTrace();
            }

            }





            share|improve this answer





















              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














               

              draft saved


              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53268086%2fis-there-a-way-to-add-a-specific-role-to-when-connecting-to-an-oracle-db-via-jbd%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              0
              down vote













              The "as sysasm" should be applied to the user:



              "jdbc:oracle:thin:"sys as sysasm/*password*"@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=host)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=+ASM)(INSTANCE_NAME=+ASM1)(UR=A)))"





              share|improve this answer

























                up vote
                0
                down vote













                The "as sysasm" should be applied to the user:



                "jdbc:oracle:thin:"sys as sysasm/*password*"@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=host)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=+ASM)(INSTANCE_NAME=+ASM1)(UR=A)))"





                share|improve this answer























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  The "as sysasm" should be applied to the user:



                  "jdbc:oracle:thin:"sys as sysasm/*password*"@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=host)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=+ASM)(INSTANCE_NAME=+ASM1)(UR=A)))"





                  share|improve this answer












                  The "as sysasm" should be applied to the user:



                  "jdbc:oracle:thin:"sys as sysasm/*password*"@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=host)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=+ASM)(INSTANCE_NAME=+ASM1)(UR=A)))"






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 13 at 7:06









                  Mureinik

                  175k21125192




                  175k21125192
























                      up vote
                      0
                      down vote













                          public void connect() throws Exception {
                      String connectString;
                      Class.forName("oracle.jdbc.driver.OracleDriver");

                      connectString = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=*host*)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=+ASM)(INSTANCE_NAME=+ASM1)(UR=A)))"

                      System.out.println("Before DriverManager.getConnection");
                      try {
                      connection = DriverManager.getConnection(connectString, "sys as sysasm", "password_for_sys");
                      System.out.println("Connection established");

                      connection.setAutoCommit(false);
                      } catch (Exception e) {
                      // TODO: handle exception
                      System.out.println("Exception inside connect(): " + e);
                      e.printStackTrace();
                      }

                      }





                      share|improve this answer

























                        up vote
                        0
                        down vote













                            public void connect() throws Exception {
                        String connectString;
                        Class.forName("oracle.jdbc.driver.OracleDriver");

                        connectString = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=*host*)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=+ASM)(INSTANCE_NAME=+ASM1)(UR=A)))"

                        System.out.println("Before DriverManager.getConnection");
                        try {
                        connection = DriverManager.getConnection(connectString, "sys as sysasm", "password_for_sys");
                        System.out.println("Connection established");

                        connection.setAutoCommit(false);
                        } catch (Exception e) {
                        // TODO: handle exception
                        System.out.println("Exception inside connect(): " + e);
                        e.printStackTrace();
                        }

                        }





                        share|improve this answer























                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                              public void connect() throws Exception {
                          String connectString;
                          Class.forName("oracle.jdbc.driver.OracleDriver");

                          connectString = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=*host*)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=+ASM)(INSTANCE_NAME=+ASM1)(UR=A)))"

                          System.out.println("Before DriverManager.getConnection");
                          try {
                          connection = DriverManager.getConnection(connectString, "sys as sysasm", "password_for_sys");
                          System.out.println("Connection established");

                          connection.setAutoCommit(false);
                          } catch (Exception e) {
                          // TODO: handle exception
                          System.out.println("Exception inside connect(): " + e);
                          e.printStackTrace();
                          }

                          }





                          share|improve this answer












                              public void connect() throws Exception {
                          String connectString;
                          Class.forName("oracle.jdbc.driver.OracleDriver");

                          connectString = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=*host*)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=+ASM)(INSTANCE_NAME=+ASM1)(UR=A)))"

                          System.out.println("Before DriverManager.getConnection");
                          try {
                          connection = DriverManager.getConnection(connectString, "sys as sysasm", "password_for_sys");
                          System.out.println("Connection established");

                          connection.setAutoCommit(false);
                          } catch (Exception e) {
                          // TODO: handle exception
                          System.out.println("Exception inside connect(): " + e);
                          e.printStackTrace();
                          }

                          }






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 13 at 7:13









                          Dmitry Demin

                          786139




                          786139






























                               

                              draft saved


                              draft discarded



















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53268086%2fis-there-a-way-to-add-a-specific-role-to-when-connecting-to-an-oracle-db-via-jbd%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              How to change which sound is reproduced for terminal bell?

                              Can I use Tabulator js library in my java Spring + Thymeleaf project?

                              Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents