Skip to content

Commit 83e80fc

Browse files
chore: regenerate README (#285)
1 parent 9cef4d5 commit 83e80fc

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

.github/readme/synth.metadata/synth.metadata

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
"git": {
55
"name": ".",
66
"remote": "https://github.com/googleapis/java-spanner-jdbc.git",
7-
"sha": "35d0936d769fea9c46216dce009a3cc78a4d9eba"
7+
"sha": "0065a9b319b09e71bf285f85c33514442a163dea"
88
}
99
},
1010
{
1111
"git": {
1212
"name": "synthtool",
1313
"remote": "https://github.com/googleapis/synthtool.git",
14-
"sha": "39b7149da4026765385403632db3c6f63db96b2c"
14+
"sha": "c2de32114ec484aa708d32012d1fa8d75232daf5"
1515
}
1616
}
1717
]

README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,31 @@ See the [Google Cloud Spanner JDBC client library docs][javadocs] to learn how t
5858
use this Google Cloud Spanner JDBC Client Library.
5959

6060

61+
### Creating a JDBC Connection
62+
63+
The following example shows how to create a JDBC connection to Cloud Spanner and execute a simple query.
64+
65+
```java
66+
String projectId = "my-project";
67+
String instanceId = "my-instance";
68+
String databaseId = "my-database";
69+
70+
try (Connection connection =
71+
DriverManager.getConnection(
72+
String.format(
73+
"jdbc:cloudspanner:/projects/%s/instances/%s/databases/%s",
74+
projectId, instanceId, databaseId))) {
75+
try (Statement statement = connection.createStatement()) {
76+
try (ResultSet rs = statement.executeQuery("SELECT CURRENT_TIMESTAMP()")) {
77+
while (rs.next()) {
78+
System.out.printf(
79+
"Connected to Cloud Spanner at [%s]%n", rs.getTimestamp(1).toString());
80+
}
81+
}
82+
}
83+
}
84+
```
85+
6186

6287

6388

@@ -101,7 +126,7 @@ Java 8 OSX | [![Kokoro CI][kokoro-badge-image-3]][kokoro-badge-link-3]
101126
Java 8 Windows | [![Kokoro CI][kokoro-badge-image-4]][kokoro-badge-link-4]
102127
Java 11 | [![Kokoro CI][kokoro-badge-image-5]][kokoro-badge-link-5]
103128

104-
[product-docs]: https://cloud.google.com/pubsub/docs/
129+
[product-docs]: https://cloud.google.com/spanner/docs/use-oss-jdbc
105130
[javadocs]: https://googleapis.dev/java/google-cloud-spanner-jdbc/latest/index.html
106131
[kokoro-badge-image-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-spanner-jdbc/java7.svg
107132
[kokoro-badge-link-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-spanner-jdbc/java7.html

0 commit comments

Comments
 (0)