diff --git a/db-application-development/adb-with-wallet/adb-with-wallet-sandbox.md b/db-application-development/adb-with-wallet/adb-with-wallet-sandbox.md index 03cecde11..6cf3dd69e 100644 --- a/db-application-development/adb-with-wallet/adb-with-wallet-sandbox.md +++ b/db-application-development/adb-with-wallet/adb-with-wallet-sandbox.md @@ -31,19 +31,21 @@ In this lab, you will: ## Task 1: Choose Autonomous Database from the services menu 1. Log in to the Oracle Cloud. -2. Once you log in, the cloud services dashboard shows all the services available to you. Click the **navigation menu** in the upper left to show top-level navigation choices. +2. Once you log in, the cloud services dashboard shows all the services available to you. Click the **navigation menu** in the upper left to show top-level navigation choices. From the top left navigation select Oracle Database and Oracle Autonomous Data Warehouse. -3. Select the allocated compartment and the region. The compartment name and the region will be available under LiveLabs My Reservations. + ![Open Navigation](images/open-adb-nav.png "Open Navigation") - ![select compartment](images/select-ll-compartment.png " ") +3. Select the allocated compartment and the region. The compartment name and the region will be available under LiveLabs **My Reservations** and **View Login info**. + ![Change compartment](images/compartment-change.png " ") + You will then be able to view the pre-provisioned Autonomous Database instance. - - ![selected compartment](images/selected-compartment-2.png " ") - - + 4. Make sure your Workload Type is __Data Warehouse__ or __All__ to see your Autonomous Data Warehouse instances. Use the __List Scope__ drop-down menu to select a compartment. 5. Click on Display Name Polyglot_Dev to view detailed information about the Autonomous Database provisioned. +6. Make note of Database version (Oracle Database 23ai), Database Name, Region + + ![database actions](images/tenancy-details.png "database actions") ## Task 2: Create a database user and tables @@ -84,9 +86,11 @@ In this lab, you will: ``` - Substitute and with the username and password of your choice. Press the green button to run the script. + Substitute and with the username and password of your choice. Press the second green button to run the script. - ![sql worksheet](images/app-user.png =50%x* "sql worksheet") + ![sql worksheet](images/create-appuser.png) + + The above example creates database user **appuser** with password **Welcome1234#**, you can use different username and password. ## Task 3: Download the wallet for this database @@ -106,9 +110,29 @@ In this lab, you will: Extract the wallet zip file to the folder of your choice. We will be using this **wallet folder** in future labs of this workshop. -## Task 4: One-way TLS connection to Oracle Autonomous Database for wallet-less connections +## Task 4: Make note of TNS Name or DNS Name + +1. Click on **Database Connection** tab, make note of TNS Names (at some places referred as DNS Name), for example DNS Name here **adbdw110890\_high** or adbdw110890\_low or adbdw110890\_medium + + ![Wallet files](images/dns-name.png) + + ![Wallet files](images/wallet-files.png) + +2. Alternatively you can download the ADB wallet and after extracting the zip file, you can check the tnsnames.ora file + + ![TNS Names](images/tns-names.png) + +3. The connection string while using connections with Database wallet would look like this example shown below + + ``` + + adbdw1212121_high = (description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.ap-sydney-1.oraclecloud.com))(connect_data=(service_name=gc454cxxxx31_adbdw1212121_high.adb.oraclecloud.com))(security=(ssl_server_dn_match=yes))) + + ``` + +## Task 5: [Optional] One-way TLS connection to Oracle Autonomous Database for wallet-less connections -> **Note:** This Task is required if you plan to use a wallet-less connection with Autonomous Database using Python or . NET. Otherwise, you can still connect to Autonomous Database using the wallet downloaded in the previous Task. +> **Please Note:** This Task is required if you plan to use a wallet-less connection with Autonomous Database using Python or . NET. Otherwise, you can still connect to Autonomous Database using the wallet downloaded in the previous Task. 1. One-way TLS connection to Oracle Autonomous Database @@ -153,11 +177,7 @@ In this lab, you will: ``` - (description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1521) - (host=adb..oraclecloud.com)) - (connect_data=(service_name=.adb.oraclecloud.com)) - (security=(ssl_server_dn_match=yes) - (ssl_server_cert_dn="CN=, OU=Oracle BMCS US, O=Oracle Corporation, L=Redwood City, ST=California, C=US"))) + adbdw110890_high = (description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.ap-sydney-1.oraclecloud.com))(connect_data=(service_name=gc454cxxxx31_adbdw110890_high.adb.oraclecloud.com))(security=(ssl_server_dn_match=yes))) ``` @@ -181,4 +201,4 @@ You may now **proceed to the next lab**. - **Author** - Madhusudhan Rao, Principal Product Manager, Database - **Contributors** - Kevin Lazarz, Senior Principal Product Manager and Christopher Jones, Senior Principal Product Manager -- **Last Updated By/Date** - Madhusudhan Rao, Aug 2022 +- **Last Updated By/Date** - Madhusudhan Rao, 4th Oct 2024 diff --git a/db-application-development/adb-with-wallet/adb-with-wallet.md b/db-application-development/adb-with-wallet/adb-with-wallet.md index 95b42bff1..308f28fc1 100644 --- a/db-application-development/adb-with-wallet/adb-with-wallet.md +++ b/db-application-development/adb-with-wallet/adb-with-wallet.md @@ -73,7 +73,7 @@ In this lab, you will: - __Deployment Type__ - For this lab, choose __Serverless__ as the deployment type. ![Create ADW screen](./images/adb-install-01.png "Create ADW screen ") - __Always Free__ - For this lab, we will leave Always Free **unchecked**. - - __Choose database version__ - Select a database version **19c** from the available versions. + - __Choose database version__ - Select a database version **19c** from the available versions. You can also select **23ai** if it is available in your tenancy and region. - **Choose network access**: For this lab, accept the default, **Secure access from everywhere**. ![Create ADW screen](./images/adb-install-04.png "Create ADW screen ") @@ -90,6 +90,7 @@ In this lab, you will: - __ECPU count__ - Number of ECPU for your service. For this lab, specify __2 ECPU__. - __Storage (TB)__ - Select your storage capacity in terabytes. For this lab, specify __1 TB__ of storage. - __Auto Scaling__ - Auto Scaling - For this lab, keep auto-scaling **unchecked**. If autoscaling is enabled, the system will automatically use up to three times more CPU and IO resources to meet workload demand. learn more about [auto scaling](https://docs.oracle.com/en/cloud/paas/autonomous-database/adbsa/autonomous-auto-scale.html) + - You can also select **23ai** if it is available in your tenancy and region. ![Create workload type](./images/adb-install-02.png "Create ADW screen ") @@ -101,6 +102,7 @@ In this lab, you will: - __Password and Confirm Password__ - Specify the password for the **ADMIN** user of the service instance. - Autonomous Database requires strong passwords. + 1. The **Contact Email** field allows you to list contacts to receive operational notices and announcements as well as unplanned maintenance notifications. This is optional. @@ -252,4 +254,4 @@ You may now **proceed to the next lab**. - **Author** - Madhusudhan Rao, Principal Product Manager, Database - **Contributors** - Kevin Lazarz, Senior Principal Product Manager and Christopher Jones, Senior Principal Product Manager - **Updates** - Database Actions and Oracle Autonomous Database creation screens updated -- **Last Updated By/Date** - Madhusudhan Rao, May 20th 2024 +- **Last Updated By/Date** - Madhusudhan Rao, 4th Oct 2024 diff --git a/db-application-development/adb-with-wallet/images/compartment-change.png b/db-application-development/adb-with-wallet/images/compartment-change.png new file mode 100644 index 000000000..b18cba011 Binary files /dev/null and b/db-application-development/adb-with-wallet/images/compartment-change.png differ diff --git a/db-application-development/adb-with-wallet/images/create-appuser.png b/db-application-development/adb-with-wallet/images/create-appuser.png new file mode 100644 index 000000000..dc56e1b97 Binary files /dev/null and b/db-application-development/adb-with-wallet/images/create-appuser.png differ diff --git a/db-application-development/adb-with-wallet/images/dns-name.png b/db-application-development/adb-with-wallet/images/dns-name.png new file mode 100644 index 000000000..350ea9864 Binary files /dev/null and b/db-application-development/adb-with-wallet/images/dns-name.png differ diff --git a/db-application-development/adb-with-wallet/images/open-adb-nav.png b/db-application-development/adb-with-wallet/images/open-adb-nav.png new file mode 100644 index 000000000..9573d1f93 Binary files /dev/null and b/db-application-development/adb-with-wallet/images/open-adb-nav.png differ diff --git a/db-application-development/adb-with-wallet/images/tenancy-details.png b/db-application-development/adb-with-wallet/images/tenancy-details.png new file mode 100644 index 000000000..b799c9db1 Binary files /dev/null and b/db-application-development/adb-with-wallet/images/tenancy-details.png differ diff --git a/db-application-development/adb-with-wallet/images/tns-names.png b/db-application-development/adb-with-wallet/images/tns-names.png new file mode 100644 index 000000000..5cf5fe510 Binary files /dev/null and b/db-application-development/adb-with-wallet/images/tns-names.png differ diff --git a/db-application-development/adb-with-wallet/images/wallet-files.png b/db-application-development/adb-with-wallet/images/wallet-files.png new file mode 100644 index 000000000..8cfa240ea Binary files /dev/null and b/db-application-development/adb-with-wallet/images/wallet-files.png differ diff --git a/db-application-development/dotnet-development/dotnet-development.md b/db-application-development/dotnet-development/dotnet-development.md index 3a8f492a9..26824a345 100644 --- a/db-application-development/dotnet-development/dotnet-development.md +++ b/db-application-development/dotnet-development/dotnet-development.md @@ -21,6 +21,7 @@ This lab assumes you have: ## Task 1: Download and Install Visual Studio Code 1. Download and install [VS Code](https://code.visualstudio.com/download). +2. Important: Please check the latest version of updated [Developing .NET Applications for Oracle Autonomous Database](https://www.oracle.com/database/technologies/appdev/dotnet/adbdotnetquickstarts.html#second-option-tab) ## Task 2: Install the .NET SDK and Visual Studio Code extensions @@ -38,14 +39,24 @@ This lab assumes you have: ![c hash extension](images/c-hash.png =50%x* "c hash extension") -6. Install the .NET Core SDK. +6. Install the .NET Core SDK [Download and install .NET Core SDK](https://dotnet.microsoft.com/download) 3.1 or higher. Click the Install button to install the extension. - ![Dotnet SDK Installation](images/dotnet-sdk.png =50%x* "Dotnet SDK Installation") + ![Dotnet SDK Installation](images/dot-net-sdk.png =30%x* "Dotnet SDK Installation") When the installation is complete, restart Visual Studio Code. + VSCode might prompt you to install C# SDK, + + ![chash sdk](images/chash-sdk.png) + + Click on Install + + ![chash kit](images/chash-kit.png) + + + ## Task 3: Develop .NET Applications for Oracle Autonomous Database with ODP.NET Core and Visual Studio Code In this Task we will be using an Autonomous Database wallet to establish a connection. Follow the below instructions to run the sample code in VS Code. @@ -74,7 +85,19 @@ In this Task we will be using an Autonomous Database wallet to establish a conne ![c hash extension](images/dotnet-obj.png "managed access core") -3. Open the **Program.cs** and copy the sample code contents below and save the file. +3. Download and extract Oracle Autonomous Database wallet in any folder + + ![Wallet folder](images/wallet-folder.png) + + Get the wallet folder path + + ![Wallet folder](images/folder-path.png) + +4. Make note of TNS name (Referred as DNS name in the below code) from Oracle Autonomous Database console + + ![Wallet folder](images/tns-name.png) + +5. Open the **Program.cs** and copy the sample code contents below and save the file. ``` @@ -124,11 +147,15 @@ In this Task we will be using an Autonomous Database wallet to establish a conne ``` + Sample code for reference. + + ![Sample Code](images/dotnet-sample-code.png) + - Substitute and depending upon the configurations in Lab 1 - OracleConfiguration.TnsAdmin (i.e. directory Autonomous Database credentials were unzipped to) - OracleConfiguration.WalletLocation (i.e. directory Autonomous Database credentials were unzipped to) -4. Run **dotnet add package Oracle.ManagedDataAccess.Core** from the command line to add ODP.NET Core to the project. +6. Run **dotnet add package Oracle.ManagedDataAccess.Core** from the command line to add ODP.NET Core to the project. ``` @@ -136,9 +163,9 @@ In this Task we will be using an Autonomous Database wallet to establish a conne ``` - ![managed access core](images/managed-access-core.png "managed access core") + ![managed access core](images/add-core.png) -5. Execute the app by running **dotnet run** from the command line. You should see the customers sample data +7. Execute the app by running **dotnet run** from the command line. You should see the customers sample data ``` @@ -146,12 +173,13 @@ In this Task we will be using an Autonomous Database wallet to establish a conne ``` - ![customer-list](images/customer-list.png =75%x* "customer-list") + ![Sample Code run](images/dotnet-results.png) -6. The entire project folder should now look as below - ![customer-list](images/proj-folder.png "customer-list") +8. The entire project folder should now look as below + + ![customer-list](images/code-folder.png ) -## Task 4: Develop .NET Applications for Oracle Autonomous Database with ODP.NET Core and Visual Studio Code (Wallet-less Connection) +## Task 4: [Optional] Develop .NET Applications for Oracle Autonomous Database with ODP.NET Core and Visual Studio Code (Wallet-less Connection) In this task, we will establish a wallet-less connection with Autonomous Database. Please follow the below instructions to run the sample code in VS Code. @@ -176,7 +204,7 @@ In this task, we will establish a wallet-less connection with Autonomous Databas 3. Access the Autonomous Database Information page, click on **DB Connection**, under Connection String, select **TLS** Option, and copy the connection string into a text file or clipboard, which we will be using in the next step. - ![tls](images/tls.png "tls") + ![tls](images/tls-copy.png "tls") 4. Open the **Program.cs** and copy the code contents below and save the file. @@ -228,13 +256,17 @@ In this task, we will establish a wallet-less connection with Autonomous Databas ``` + Sample code for reference + + ![Walletless](images/dotnet-walletless.png) + Substitute , and depending upon the string that we copied in previous step. > **Note:** Your Data Source connection string in the above code might look like this below. Add the \ escape sequence in front of the quotes. ``` - "Data Source =(description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1521)(host=adb..oraclecloud.com))(connect_data=(service_name=__high.adb.oraclecloud.com))(security=(ssl_server_dn_match=yes)(ssl_server_cert_dn=\"CN=adwc..oraclecloud.com, OU=Oracle BMCS US, O=Oracle Corporation,L=Redwood City, ST=California, C=US\"))) "; + "(description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1521)(host=adb.ap-sydney-1.oraclecloud.com))(connect_data=(service_name=gc454c29a9ca831_adbdw110890_high.adb.oraclecloud.com))(security=(ssl_server_dn_match=yes)))"; ``` @@ -258,11 +290,11 @@ In this task, we will establish a wallet-less connection with Autonomous Databas ``` - ![customer-list](images/customer-list.png =75%x* "customer-list") + ![Sample Code run](images/dotnet-results.png) The output will be the same as Task 3 but with only difference being this time we are establishing wallet-less connection. -## Task 5: Utilize the Oracle Developer Tools For VS Code extension to explore database schema and run SQL scripts + ## Learn More @@ -316,4 +348,4 @@ This Lab task shows how to use Oracle Developer Tools for VS Code, Connect to Au - **Author** - Madhusudhan Rao, Principal Product Manager, Database * **Contributors** - Kevin Lazarz, Senior Principal Product Manager, Database. Alex Keh, Senior Principal Product Manager and Christian Shay, Senior Principal Product Manager -* **Last Updated By/Date** - Madhusudhan Rao, June 28th 2022 +* **Last Updated By/Date** - Madhusudhan Rao, Oct 6th, 2024 diff --git a/db-application-development/dotnet-development/images/add-core.png b/db-application-development/dotnet-development/images/add-core.png new file mode 100644 index 000000000..31b0ce2df Binary files /dev/null and b/db-application-development/dotnet-development/images/add-core.png differ diff --git a/db-application-development/dotnet-development/images/chash-kit.png b/db-application-development/dotnet-development/images/chash-kit.png new file mode 100644 index 000000000..126e12b1c Binary files /dev/null and b/db-application-development/dotnet-development/images/chash-kit.png differ diff --git a/db-application-development/dotnet-development/images/chash-sdk.png b/db-application-development/dotnet-development/images/chash-sdk.png new file mode 100644 index 000000000..8cb776542 Binary files /dev/null and b/db-application-development/dotnet-development/images/chash-sdk.png differ diff --git a/db-application-development/dotnet-development/images/code-folder.png b/db-application-development/dotnet-development/images/code-folder.png new file mode 100644 index 000000000..10295ad48 Binary files /dev/null and b/db-application-development/dotnet-development/images/code-folder.png differ diff --git a/db-application-development/dotnet-development/images/dot-net-sdk.png b/db-application-development/dotnet-development/images/dot-net-sdk.png new file mode 100644 index 000000000..1792e50d3 Binary files /dev/null and b/db-application-development/dotnet-development/images/dot-net-sdk.png differ diff --git a/db-application-development/dotnet-development/images/dotnet-results.png b/db-application-development/dotnet-development/images/dotnet-results.png new file mode 100644 index 000000000..2e067c2f9 Binary files /dev/null and b/db-application-development/dotnet-development/images/dotnet-results.png differ diff --git a/db-application-development/dotnet-development/images/dotnet-sample-code.png b/db-application-development/dotnet-development/images/dotnet-sample-code.png new file mode 100644 index 000000000..e6c1fe3bf Binary files /dev/null and b/db-application-development/dotnet-development/images/dotnet-sample-code.png differ diff --git a/db-application-development/dotnet-development/images/dotnet-walletless.png b/db-application-development/dotnet-development/images/dotnet-walletless.png new file mode 100644 index 000000000..786440a07 Binary files /dev/null and b/db-application-development/dotnet-development/images/dotnet-walletless.png differ diff --git a/db-application-development/dotnet-development/images/folder-path.png b/db-application-development/dotnet-development/images/folder-path.png new file mode 100644 index 000000000..63d79e9f3 Binary files /dev/null and b/db-application-development/dotnet-development/images/folder-path.png differ diff --git a/db-application-development/dotnet-development/images/tls-copy.png b/db-application-development/dotnet-development/images/tls-copy.png new file mode 100644 index 000000000..a2487cf79 Binary files /dev/null and b/db-application-development/dotnet-development/images/tls-copy.png differ diff --git a/db-application-development/dotnet-development/images/tns-name.png b/db-application-development/dotnet-development/images/tns-name.png new file mode 100644 index 000000000..e795f01b8 Binary files /dev/null and b/db-application-development/dotnet-development/images/tns-name.png differ diff --git a/db-application-development/dotnet-development/images/wallet-folder.png b/db-application-development/dotnet-development/images/wallet-folder.png new file mode 100644 index 000000000..9ab97137e Binary files /dev/null and b/db-application-development/dotnet-development/images/wallet-folder.png differ diff --git a/db-application-development/introduction/introduction.md b/db-application-development/introduction/introduction.md index dee49bce6..ed52b39e2 100644 --- a/db-application-development/introduction/introduction.md +++ b/db-application-development/introduction/introduction.md @@ -37,4 +37,5 @@ The objective of this workshop is: - Kuassi MENSAH, Director of Product Management. - Alex Keh, Senior Principal Product Manager. - Christian Shay, Senior Principal Product Manager. -* **Last Updated By/Date** - Madhusudhan Rao, June 28th 2022 + - Sharad Chandran R, Principal Product Manager +* **Last Updated By/Date** - Madhusudhan Rao, Oct 7th 2024 diff --git a/db-application-development/javadb-development/javadb-development.md b/db-application-development/javadb-development/javadb-development.md index 3959c4927..3f1bec8ce 100644 --- a/db-application-development/javadb-development/javadb-development.md +++ b/db-application-development/javadb-development/javadb-development.md @@ -108,48 +108,25 @@ unzip Wallet_DEMOADW.zip -d $HOME/< path to wallet folder> [Download latest Source code from Oracle samples](https://github.com/oracle-samples/oracle-db-examples/blob/main/java/jdbc/ConnectionSamples/DataSourceSample.java) ``` - - /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.*/ - /* - DESCRIPTION - The code sample shows how to use the DataSource API to establish a connection - to the Database. You can specify properties with "setConnectionProperties". - This is the recommended way to create connections to the Database. - - Note that an instance of oracle.jdbc.pool.OracleDataSource doesn't provide - any connection pooling. It's just a connection factory. A connection pool, - such as Universal Connection Pool (UCP), can be configured to use an - instance of oracle.jdbc.pool.OracleDataSource to create connections and - then cache them. - - Step 1: Enter the Database details in this file. - DB_USER, DB_PASSWORD and DB_URL are required - Step 2: Run the sample with "ant DataSourceSample" - - NOTES - Use JDK 1.7 and above - - MODIFIED (MM/DD/YY) - nbsundar 02/17/15 - Creation - */ - - import java.io.IOException; - import java.io.InputStream; - import java.sql.Connection; - import java.sql.ResultSet; - import java.sql.SQLException; - import java.sql.Statement; - import java.util.Properties; - - import oracle.jdbc.pool.OracleDataSource; - import oracle.jdbc.OracleConnection; - import java.sql.DatabaseMetaData; - - public class DataSourceSample { + + import java.io.IOException; + import java.io.InputStream; + import java.sql.Connection; + import java.sql.ResultSet; + import java.sql.SQLException; + import java.sql.Statement; + import java.util.Properties; + + import oracle.jdbc.pool.OracleDataSource; + import oracle.jdbc.OracleConnection; + import java.sql.DatabaseMetaData; + + public class DataSourceSample { // The recommended format of a connection URL is the long format with the // connection descriptor. //final static String DB_URL= "jdbc:oracle:thin:@myhost:1521/myorcldbservicename"; // For ATP and ADW - use the TNS Alias name along with the TNS_ADMIN when using 18.3 JDBC driver + // Please refer Lab 1 on how to get TNS Names final static String DB_URL="jdbc:oracle:thin:@a_high?TNS_ADMIN=/"; // final static String DB_URL="jdbc:oracle:thin:@adbdw110612_high?TNS_ADMIN=/Users/username/Workarea/Polyglot/wallet/Wallet_ADBDW110612"; // In case of windows, use the following URL @@ -167,48 +144,48 @@ unzip Wallet_DEMOADW.zip -d $HOME/< path to wallet folder> * the OracleConnection interface to find more. */ public static void main(String args[]) throws SQLException { - Properties info = new Properties(); - info.put(OracleConnection.CONNECTION_PROPERTY_USER_NAME, DB_USER); - info.put(OracleConnection.CONNECTION_PROPERTY_PASSWORD, DB_PASSWORD); - info.put(OracleConnection.CONNECTION_PROPERTY_DEFAULT_ROW_PREFETCH, "20"); + Properties info = new Properties(); + info.put(OracleConnection.CONNECTION_PROPERTY_USER_NAME, DB_USER); + info.put(OracleConnection.CONNECTION_PROPERTY_PASSWORD, DB_PASSWORD); + info.put(OracleConnection.CONNECTION_PROPERTY_DEFAULT_ROW_PREFETCH, "20"); - OracleDataSource ods = new OracleDataSource(); - ods.setURL(DB_URL); - ods.setConnectionProperties(info); - - // With AutoCloseable, the connection is closed automatically. - try (OracleConnection connection = (OracleConnection) ods.getConnection()) { - // Get the JDBC driver name and version - DatabaseMetaData dbmd = connection.getMetaData(); - System.out.println("Driver Name: " + dbmd.getDriverName()); - System.out.println("Driver Version: " + dbmd.getDriverVersion()); - // Print some connection properties - System.out.println("Default Row Prefetch Value is: " + - connection.getDefaultRowPrefetch()); - System.out.println("Database Username is: " + connection.getUserName()); - System.out.println(); - // Perform a database operation - printEmployees(connection); - } + OracleDataSource ods = new OracleDataSource(); + ods.setURL(DB_URL); + ods.setConnectionProperties(info); + + // With AutoCloseable, the connection is closed automatically. + try (OracleConnection connection = (OracleConnection) ods.getConnection()) { + // Get the JDBC driver name and version + DatabaseMetaData dbmd = connection.getMetaData(); + System.out.println("Driver Name: " + dbmd.getDriverName()); + System.out.println("Driver Version: " + dbmd.getDriverVersion()); + // Print some connection properties + System.out.println("Default Row Prefetch Value is: " + + connection.getDefaultRowPrefetch()); + System.out.println("Database Username is: " + connection.getUserName()); + System.out.println(); + // Perform a database operation + printEmployees(connection); + } } /* * Displays first_name and last_name from the employees table. */ public static void printEmployees(Connection connection) throws SQLException { - // Statement and ResultSet are AutoCloseable and closed automatically. - try (Statement statement = connection.createStatement()) { - try (ResultSet resultSet = statement - .executeQuery("select * from sales360 where rownum < 10")) { - System.out.println("cust_id" + " " + "channel_id"); - System.out.println("---------------------"); - while (resultSet.next()) - System.out.println(resultSet.getString(1) + " " - + resultSet.getString(2) + " "); - } - } + // Statement and ResultSet are AutoCloseable and closed automatically. + try (Statement statement = connection.createStatement()) { + try (ResultSet resultSet = statement + .executeQuery("select * from sales360 where rownum < 10")) { + System.out.println("cust_id" + " " + "channel_id"); + System.out.println("---------------------"); + while (resultSet.next()) + System.out.println(resultSet.getString(1) + " " + + resultSet.getString(2) + " "); + } + } } - } + } ``` @@ -248,4 +225,4 @@ unzip Wallet_DEMOADW.zip -d $HOME/< path to wallet folder> * **Author** - Madhusudhan Rao, Principal Product Manager, Database * **Contributors** - Kevin Lazarz, Senior Principal Product Manager and Kuassi MENSAH, Director of Product Management -* **Last Updated By/Date** - Madhusudhan Rao, 4th Oct 2024. \ No newline at end of file +* **Last Updated By/Date** - Madhusudhan Rao, 7th Oct 2024. \ No newline at end of file diff --git a/db-application-development/pythondb-development-oracledb/images/copy-connection.png b/db-application-development/pythondb-development-oracledb/images/copy-connection.png new file mode 100644 index 000000000..66bc11a6f Binary files /dev/null and b/db-application-development/pythondb-development-oracledb/images/copy-connection.png differ diff --git a/db-application-development/pythondb-development-oracledb/images/install-oracledb.png b/db-application-development/pythondb-development-oracledb/images/install-oracledb.png new file mode 100644 index 000000000..c65bf7fe2 Binary files /dev/null and b/db-application-development/pythondb-development-oracledb/images/install-oracledb.png differ diff --git a/db-application-development/pythondb-development-oracledb/images/python-code.png b/db-application-development/pythondb-development-oracledb/images/python-code.png index 1d151959b..d0d198464 100644 Binary files a/db-application-development/pythondb-development-oracledb/images/python-code.png and b/db-application-development/pythondb-development-oracledb/images/python-code.png differ diff --git a/db-application-development/pythondb-development-oracledb/images/run-python-code.png b/db-application-development/pythondb-development-oracledb/images/run-python-code.png new file mode 100644 index 000000000..4db48e457 Binary files /dev/null and b/db-application-development/pythondb-development-oracledb/images/run-python-code.png differ diff --git a/db-application-development/pythondb-development-oracledb/images/sample-walletless-code.png b/db-application-development/pythondb-development-oracledb/images/sample-walletless-code.png new file mode 100644 index 000000000..d96f16744 Binary files /dev/null and b/db-application-development/pythondb-development-oracledb/images/sample-walletless-code.png differ diff --git a/db-application-development/pythondb-development-oracledb/pythondb-development-oracledb.md b/db-application-development/pythondb-development-oracledb/pythondb-development-oracledb.md index ab56735c5..4af52d3e1 100644 --- a/db-application-development/pythondb-development-oracledb/pythondb-development-oracledb.md +++ b/db-application-development/pythondb-development-oracledb/pythondb-development-oracledb.md @@ -26,8 +26,8 @@ Estimated Time: 20 minutes In this lab, you will: -* Write Python code to access Oracle Database using python-oracledb with an Autonomous Database wallet. - +* Write Python code to access Oracle Database using python-oracledb with an Autonomous Database wallet. +* Run Python code without an Autonomous Database wallet (wallet-less) using a One-way TLS connection string copied from Lab 1 ### Prerequisites @@ -35,6 +35,8 @@ This lab assumes: * An Autonomous Database has been created. * A wallet has been downloaded. +* One-way TLS connection has been configured. +* Please Note: On few Beta versions of Mac OS, the wallet less code might not work ## Task 1: Install python @@ -81,8 +83,10 @@ Use Python 3.6 to 3.10. Install [Python 3](https://yum.oracle.com/oracle-linux-p python3 -m pip install oracledb --upgrade --user ``` + + ![Install oracledb](images/install-oracledb.png) -## Task 3: Develop a Python application using a wallet +## Task 3: Develop a Python Application using a wallet 1. In this Task, we will develop a Python application using an Autonomous Database wallet. For python-oracledb in Thin mode, only two files from the wallet zip file are required. @@ -118,14 +122,17 @@ Use Python 3.6 to 3.10. Install [Python 3](https://yum.oracle.com/oracle-linux-p wall_pwd = "" # connection string name for example demoadw_high - dsn_name = "" + # please check tnsnames.ora file in your database wallet to get tns_name + # or refer Lab 1 for more details + + tns_name = "" # for example - # dsn_name = "adbdw110612_high" + # tns_name = "adbdw110612_high" connection = oracledb.connect(user=username, password=user_pwd, - dsn=dsn_name, + dsn=tns_name, config_dir=wall_config_dir, wallet_location=wall_config_dir, wallet_password=wall_pwd) @@ -151,13 +158,14 @@ Use Python 3.6 to 3.10. Install [Python 3](https://yum.oracle.com/oracle-linux-p ![Python Code](images/python-code.png) - + You will now be able to view customer data from customers360 table. + + ![Run Python Code Walletless](images/run-python-code.png) - You successfully made it to the end this of this. You may now **proceed to the next lab**. + You successfully made it to the end this of this. You may now **proceed to the next lab**. ## Learn More +* [Quick Start: Developing Python Applications for Oracle Autonomous Database](https://www.oracle.com/database/technologies/appdev/python/quickstartpython.html) * [python-oracledb documentation](https://python-oracledb.readthedocs.io/en/latest/index.html) * [Easy wallet-less connections to Oracle Autonomous Databases in Python](https://blogs.oracle.com/opal/post/easy-way-to-connect-python-applications-to-oracle-autonomous-databases) * [Code Examples: python-oracledb](https://github.com/oracle/python-oracledb) * [Installing python-oracledb](https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html) +* [Getting Started with Python and Oracle Database](https://apexapps.oracle.com/pls/apex/r/dbpm/livelabs/view-workshop?wid=3482) ## Acknowledgements * **Author** - Madhusudhan Rao, Principal Product Manager, Database -* **Contributors** - Kevin Lazarz, Senior Principal Product Manager and Christopher Jones, Senior Principal Product Manager +* **Contributors** - Kevin Lazarz, Senior Principal Product Manager and Christopher Jones, Senior Principal Product Manager, Sharad Chandran R, Principal Product Manager * **Last Updated By/Date** - Madhusudhan Rao, 4th Oct 2024.