{
  "date": "2020-08-13T16:26:22",
  "slug": "oracle-adb-rename",
  "link": "https://www.dbi-services.com/blog/oracle-adb-rename/",
  "title": {
    "rendered": "Oracle ADB: rename the service_name connect_data"
  },
  "content": {
    "rendered": "<h2>By Franck Pachot</h2>\n<p>.<br />\nSince Aug. 4, 2020 we have the possibility to rename an Autonomous Database (ATP, ADW or AJD &#8211; the latest JSON database) on shared Exadata infrastructure (what was called &#8216;serverless&#8217; last year which is a PDB in a public CDB). As the PDB name is internal, we reference the ADB with its database name is actually a part of the service name.</p>\n<p>I have an ATP database that I&#8217;ve created in the Oracle Cloud Free Tier a few months ago.<br />\nI have downloaded the region and instance wallet to be used by client connections:</p>\n<pre><code>\nSQL&gt; host grep _high /var/tmp/Wallet_DB202005052234_instance/tnsnames.ora\n\ndb202005052234_high = (description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.eu-frankfurt-1.oraclecloud.com))(connect_data=(service_name=jgp1nyc204pdpjc_db202005052234_high.atp.oraclecloud.com))(security=(ssl_server_cert_dn=\"CN=adwc.eucom-central-1.oraclecloud.com,OU=Oracle BMCS FRANKFURT,O=Oracle Corporation,L=Redwood City,ST=California,C=US\")))\n</code></pre>\n<p>This is the instance wallet which references only this database (db202005052234)</p>\n<pre><code>\nSQL&gt; host grep _high /var/tmp/Wallet_DB202005052234_region/tnsnames.ora\n\ndb202005052234_high = (description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.eu-frankfurt-1.oraclecloud.com))(connect_data=(service_name=jgp1nyc204pdpjc_db202005052234_high.atp.oraclecloud.com))(security=(ssl_server_cert_dn=\"CN=adwc.eucom-central-1.oraclecloud.com,OU=Oracle BMCS FRANKFURT,O=Oracle Corporation,L=Redwood City,ST=California,C=US\")))\ndb202003061855_high = (description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.eu-frankfurt-1.oraclecloud.com))(connect_data=(service_name=jgp1nyc204pdpjc_db202003061855_high.adwc.oraclecloud.com))(security=(ssl_server_cert_dn=\"CN=adwc.eucom-central-1.oraclecloud.com,OU=Oracle BMCS FRANKFURT,O=Oracle Corporation,L=Redwood City,ST=California,C=US\")))\n</code></pre>\n<p>This contains also my other database service that I have in the same region.</p>\n<p>I connect using this wallet:</p>\n<pre><code>\nSQL&gt; connect admin/\"TheAnswer:=42\"@DB202005052234_tp?TNS_ADMIN=/var/tmp/Wallet_DB202005052234_instance\nConnected.\n\nSQL&gt; select name,network_name,creation_date,pdb from v$services;\n\n                                                          NAME                                                   NETWORK_NAME          CREATION_DATE                               PDB\n______________________________________________________________ ______________________________________________________________ ______________________ _________________________________\nJGP1NYC204PDPJC_DB202005052234_high.atp.oraclecloud.com        JGP1NYC204PDPJC_DB202005052234_high.atp.oraclecloud.com        2019-05-17 20:53:03    JGP1NYC204PDPJC_DB202005052234\nJGP1NYC204PDPJC_DB202005052234_tpurgent.atp.oraclecloud.com    JGP1NYC204PDPJC_DB202005052234_tpurgent.atp.oraclecloud.com    2019-05-17 20:53:03    JGP1NYC204PDPJC_DB202005052234\nJGP1NYC204PDPJC_DB202005052234_low.atp.oraclecloud.com         JGP1NYC204PDPJC_DB202005052234_low.atp.oraclecloud.com         2019-05-17 20:53:03    JGP1NYC204PDPJC_DB202005052234\nJGP1NYC204PDPJC_DB202005052234_tp.atp.oraclecloud.com          JGP1NYC204PDPJC_DB202005052234_tp.atp.oraclecloud.com          2019-05-17 20:53:03    JGP1NYC204PDPJC_DB202005052234\njgp1nyc204pdpjc_db202005052234                                 jgp1nyc204pdpjc_db202005052234                                 2020-08-13 09:02:02    JGP1NYC204PDPJC_DB202005052234\nJGP1NYC204PDPJC_DB202005052234_medium.atp.oraclecloud.com      JGP1NYC204PDPJC_DB202005052234_medium.atp.oraclecloud.com      2019-05-17 20:53:03    JGP1NYC204PDPJC_DB202005052234\n</code></pre>\n<p>Here are all the services registered: the LOW/MEDIUM/HIGH/TP/TP_URGENT for my connections and the PDB name one.</p>\n<p>Now from the Cloud Console I rename the database:</p>\n<p><a href=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/Annotation-2020-08-13-120923.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-42429\" src=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/Annotation-2020-08-13-120923.jpg\" alt=\"\" width=\"1024\" height=\"622\" /></a></p>\n<p>You can see that the &#8220;display name&#8221; (DB 202008131439) didn&#8217;t change but the &#8220;Database name&#8221; has been renamed (from &#8220;DB202008131439&#8221; to &#8220;FRANCK&#8221;).</p>\n<pre><code>\nSQL&gt; select name,network_name,creation_date,pdb from v$services;\n\nError starting at line : 1 in command -\nselect name,network_name,creation_date,pdb from v$services\nError at Command Line : 1 Column : 1\nError report -\nSQL Error: No more data to read from socket\nSQL&gt;\n</code></pre>\n<p>My connection has been canceled. I need to connect again.</p>\n<pre><code>\nSQL&gt; connect admin/\"TheAnswer:=42\"@DB202005052234_tp?TNS_ADMIN=/var/tmp/Wallet_DB202005052234_instance\nAug 13, 2020 10:13:41 AM oracle.net.resolver.EZConnectResolver parseExtendedProperties\nSEVERE: Extended settings parsing failed.\njava.lang.RuntimeException: Unable to parse url \"/var/tmp/Wallet_DB202005052234_instance:1521/DB202005052234_tp?TNS_ADMIN\"\n        at oracle.net.resolver.EZConnectResolver.parseExtendedProperties(EZConnectResolver.java:408)\n        at oracle.net.resolver.EZConnectResolver.parseExtendedSettings(EZConnectResolver.java:366)\n        at oracle.net.resolver.EZConnectResolver.parse(EZConnectResolver.java:171)\n        at oracle.net.resolver.EZConnectResolver.(EZConnectResolver.java:130)\n        at oracle.net.resolver.EZConnectResolver.newInstance(EZConnectResolver.java:139)\n        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:669)\n        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:562)\n        at java.sql.DriverManager.getConnection(DriverManager.java:664)\n        at java.sql.DriverManager.getConnection(DriverManager.java:208)\n        at oracle.dbtools.raptor.newscriptrunner.SQLPLUS.connect(SQLPLUS.java:5324)\n        at oracle.dbtools.raptor.newscriptrunner.SQLPLUS.logConnectionURL(SQLPLUS.java:5418)\n        at oracle.dbtools.raptor.newscriptrunner.SQLPLUS.logConnectionURL(SQLPLUS.java:5342)\n        at oracle.dbtools.raptor.newscriptrunner.SQLPLUS.getConnection(SQLPLUS.java:5154)\n        at oracle.dbtools.raptor.newscriptrunner.SQLPLUS.runConnect(SQLPLUS.java:2414)\n        at oracle.dbtools.raptor.newscriptrunner.SQLPLUS.run(SQLPLUS.java:220)\n        at oracle.dbtools.raptor.newscriptrunner.ScriptRunner.runSQLPLUS(ScriptRunner.java:425)\n        at oracle.dbtools.raptor.newscriptrunner.ScriptRunner.run(ScriptRunner.java:262)\n        at oracle.dbtools.raptor.newscriptrunner.ScriptExecutor.run(ScriptExecutor.java:344)\n        at oracle.dbtools.raptor.newscriptrunner.ScriptExecutor.run(ScriptExecutor.java:227)\n        at oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli.process(SqlCli.java:410)\n        at oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli.processLine(SqlCli.java:421)\n        at oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli.startSQLPlus(SqlCli.java:1179)\n        at oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli.main(SqlCli.java:502)\n\n  USER          = admin\n  URL           = jdbc:oracle:thin:@DB202005052234_tp?TNS_ADMIN=/var/tmp/Wallet_DB202005052234_instance\n  Error Message = Listener refused the connection with the following error:\nORA-12514, TNS:listener does not currently know of service requested in connect descriptor\n  USER          = admin\n  URL           = jdbc:oracle:thin:@DB202005052234_tp?TNS_ADMIN=/var/tmp/Wallet_DB202005052234_instance:1521/DB202005052234_tp?TNS_ADMIN=/var/tmp/Wallet_DB202005052234_instance\n  Error Message = IO Error: Invalid connection string format, a valid format is: \"host:port:sid\"\n\nWarning: You are no longer connected to ORACLE.\nSQL&gt;\n</code></pre>\n<p>The service is not known, which makes sense because the rename of the database is actually a rename of the services.</p>\n<p>Oracle <a href=\"https://docs.oracle.com/en/cloud/paas/autonomous-data-warehouse-cloud/user/autonomous-rename.html#GUID-E83E85D3-6D76-4E82-8570-8C10D07B46C4\" target=\"_blank\" rel=\"noopener noreferrer\">documentation </a>says that we have to download the wallet again after a rename of the database. But that&#8217;s not very agile. Let&#8217;s rename the service in the tnsnames.ora</p>\n<pre><code>\nSQL&gt; host sed -ie s/_db202005052234/FRANCK/g /var/tmp/Wallet_DB202005052234_instance/tnsnames.ora\n</code></pre>\n<p>This changes only the SERVICE_NAME in CONNECT_DATA but not the tnsnames.ora entry, then I can use the same connection string.</p>\n<pre><code>\nSQL&gt; connect admin/\"TheAnswer:=42\"@DB202005052234_tp?TNS_ADMIN=/var/tmp/Wallet_DB202005052234_instance\n\nSQL&gt; select name,network_name,creation_date,pdb from v$services;\n\n                                                  NAME                                           NETWORK_NAME          CREATION_DATE                       PDB\n______________________________________________________ ______________________________________________________ ______________________ _________________________\nJGP1NYC204PDPJC_FRANCK_high.atp.oraclecloud.com        JGP1NYC204PDPJC_FRANCK_high.atp.oraclecloud.com        2019-05-17 20:53:03    JGP1NYC204PDPJC_FRANCK\nJGP1NYC204PDPJC_FRANCK_tp.atp.oraclecloud.com          JGP1NYC204PDPJC_FRANCK_tp.atp.oraclecloud.com          2019-05-17 20:53:03    JGP1NYC204PDPJC_FRANCK\nJGP1NYC204PDPJC_FRANCK_medium.atp.oraclecloud.com      JGP1NYC204PDPJC_FRANCK_medium.atp.oraclecloud.com      2019-05-17 20:53:03    JGP1NYC204PDPJC_FRANCK\njgp1nyc204pdpjc_franck                                 jgp1nyc204pdpjc_franck                                 2020-08-13 10:05:58    JGP1NYC204PDPJC_FRANCK\nJGP1NYC204PDPJC_FRANCK_low.atp.oraclecloud.com         JGP1NYC204PDPJC_FRANCK_low.atp.oraclecloud.com         2019-05-17 20:53:03    JGP1NYC204PDPJC_FRANCK\nJGP1NYC204PDPJC_FRANCK_tpurgent.atp.oraclecloud.com    JGP1NYC204PDPJC_FRANCK_tpurgent.atp.oraclecloud.com    2019-05-17 20:53:03    JGP1NYC204PDPJC_FRANCK\n\n</code></pre>\n<p>Using the new SERVICE_NAME is sufficient. As you can see above, some autonomous magic remains: the new services still have the old creation date.</p>\n<p>Note that you should follow the documentation and download the wallet and change your connection string. There is probably a reason behind this. But autonomous or not, I like to understand what I do and I don&#8217;t see any reason for changing everything when renaming a service.</p>\n",
    "protected": false
  }
}
