Skip to content

Commit

Permalink
Update AWS Example and make "s3://" optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ting-lan-wang committed Jan 16, 2025
1 parent 6e099f1 commit b5a9f95
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public InputStream getJson(String s3Url) throws SQLException {

URI uri = null;
try {
uri = new URI(s3Url);
uri = getURI(s3Url);
} catch (URISyntaxException uriSyntaxException) {
throw new SQLException(uriSyntaxException);
}
Expand All @@ -53,4 +53,11 @@ public InputStream getJson(String s3Url) throws SQLException {
public String getType() {
return "awss3";
}

private URI getURI(String s3Url) throws URISyntaxException {
if (!s3Url.startsWith("s3://")) {
s3Url = "s3://" + s3Url;
}
return new URI(s3Url);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,28 @@
import java.sql.SQLException;
import java.sql.Statement;

/**
* A standalone example that configures Oracle JDBC to be provided with the
* connection properties retrieved from AWS S3.
*/
public class AwsS3Example {
private static String url;

/**
* <p>
* A simple example to retrieve connection properties from AWS S3.
* </p><p>
* For the default authentication, the only required local configuration is
* to have a valid AWS Config in ~/.aws/config and ~/.aws/credentials.
* </p>
* @param args the command line arguments
* @throws SQLException if an error occurs during the database calls
*/
public static void main(String[] args) throws SQLException {

// Sample default URL if non present
if (args.length == 0) {
// url = "jdbc:oracle:thin:@config-awss3://s3://{bucket-name}/{key-name}";
url = "jdbc:oracle:thin:@config-awss3://s3://tinglwan-general-bucket/folder1/payload_ojdbc_adb_aws_secret.json";
// url = "jdbc:oracle:thin:@config-file:///Users/tinglwang/Notes/ojdbc-plugins/ociobject/payload_ojdbc_wallet_location_base64_sso.json";
url = "jdbc:oracle:thin:@config-awss3://{bucket-name}/{key-name}";
} else {
url = args[0];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
package oracle.jdbc.provider.aws.configuration;

import oracle.jdbc.datasource.impl.OracleDataSource;
import oracle.jdbc.provider.oci.configuration.ObjectStorageExample;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
* A standalone example that configures Oracle JDBC to be provided with the
* connection properties retrieved from AWS Secrets Manager.
*/
public class AwsSecretsManagerConfigurationExample {
private static String url;

/**
* <p>
* A simple example to retrieve connection properties from AWS Secrets Manager.
* </p><p>
* For the default authentication, the only required local configuration is
* to have a valid AWS Config in ~/.aws/config and ~/.aws/credentials.
* </p>
* @param args the command line arguments
* @throws SQLException if an error occurs during the database calls
*/
public static void main(String[] args) throws SQLException {

// Sample default URL if non present
Expand Down

0 comments on commit b5a9f95

Please sign in to comment.