Skip to content

Commit c1286fc

Browse files
committed
Update AWS Example and make "s3://" optional
1 parent b3f4531 commit c1286fc

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed

ojdbc-provider-aws/src/main/java/oracle/jdbc/provider/aws/configuration/AwsS3ConfigurationProvider.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public InputStream getJson(String s3Url) throws SQLException {
2929

3030
URI uri = null;
3131
try {
32-
uri = new URI(s3Url);
32+
uri = getURI(s3Url);
3333
} catch (URISyntaxException uriSyntaxException) {
3434
throw new SQLException(uriSyntaxException);
3535
}
@@ -53,4 +53,11 @@ public InputStream getJson(String s3Url) throws SQLException {
5353
public String getType() {
5454
return "awss3";
5555
}
56+
57+
private URI getURI(String s3Url) throws URISyntaxException {
58+
if (!s3Url.startsWith("s3://")) {
59+
s3Url = "s3://" + s3Url;
60+
}
61+
return new URI(s3Url);
62+
}
5663
}

ojdbc-provider-samples/src/main/java/oracle/jdbc/provider/aws/configuration/AwsS3Example.java

+16-3
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,28 @@
4444
import java.sql.SQLException;
4545
import java.sql.Statement;
4646

47+
/**
48+
* A standalone example that configures Oracle JDBC to be provided with the
49+
* connection properties retrieved from AWS S3.
50+
*/
4751
public class AwsS3Example {
4852
private static String url;
53+
54+
/**
55+
* <p>
56+
* A simple example to retrieve connection properties from AWS S3.
57+
* </p><p>
58+
* For the default authentication, the only required local configuration is
59+
* to have a valid AWS Config in ~/.aws/config and ~/.aws/credentials.
60+
* </p>
61+
* @param args the command line arguments
62+
* @throws SQLException if an error occurs during the database calls
63+
*/
4964
public static void main(String[] args) throws SQLException {
5065

5166
// Sample default URL if non present
5267
if (args.length == 0) {
53-
// url = "jdbc:oracle:thin:@config-awss3://s3://{bucket-name}/{key-name}";
54-
url = "jdbc:oracle:thin:@config-awss3://s3://tinglwan-general-bucket/folder1/payload_ojdbc_adb_aws_secret.json";
55-
// url = "jdbc:oracle:thin:@config-file:///Users/tinglwang/Notes/ojdbc-plugins/ociobject/payload_ojdbc_wallet_location_base64_sso.json";
68+
url = "jdbc:oracle:thin:@config-awss3://{bucket-name}/{key-name}";
5669
} else {
5770
url = args[0];
5871
}

ojdbc-provider-samples/src/main/java/oracle/jdbc/provider/aws/configuration/AwsSecretsManagerConfigurationExample.java

+16
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
11
package oracle.jdbc.provider.aws.configuration;
22

33
import oracle.jdbc.datasource.impl.OracleDataSource;
4+
import oracle.jdbc.provider.oci.configuration.ObjectStorageExample;
45

56
import java.sql.Connection;
67
import java.sql.ResultSet;
78
import java.sql.SQLException;
89
import java.sql.Statement;
910

11+
/**
12+
* A standalone example that configures Oracle JDBC to be provided with the
13+
* connection properties retrieved from AWS Secrets Manager.
14+
*/
1015
public class AwsSecretsManagerConfigurationExample {
1116
private static String url;
17+
18+
/**
19+
* <p>
20+
* A simple example to retrieve connection properties from AWS Secrets Manager.
21+
* </p><p>
22+
* For the default authentication, the only required local configuration is
23+
* to have a valid AWS Config in ~/.aws/config and ~/.aws/credentials.
24+
* </p>
25+
* @param args the command line arguments
26+
* @throws SQLException if an error occurs during the database calls
27+
*/
1228
public static void main(String[] args) throws SQLException {
1329

1430
// Sample default URL if non present

0 commit comments

Comments
 (0)