Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed JDBC string splitting delimiter #1233

Merged
merged 5 commits into from
Sep 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions jdbc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,24 @@ db.passwd=admin

Be sure to use your driver class, a valid JDBC connection string, and credentials to your database.

For connection fail-over in a DBMS cluster specify the connection string as follows (example based on Postgres):

```sh
db.driver=org.postgresql.Driver
db.url=jdbc:postgresql://IP1:PORT1,IP2:PORT2,IP3:PORT3/ycsb
db.user=admin
db.passwd=admin
```

For using multiple shards in a DBMS cluster specify the connection string as follows by using `;`as delimiter (example based on PostgreSQL):

```sh
db.driver=org.postgresql.Driver
db.url=jdbc:postgresql://host1:port1/ycsb;jdbc:postgresql://host2:port2/ycsb
db.user=admin
db.passwd=admin
```

You can add these to your workload configuration or a separate properties file and specify it with ```-P``` or you can add the properties individually to your ycsb command with ```-p```.

### 5. Add your JDBC Driver to the classpath
Expand Down Expand Up @@ -115,8 +133,3 @@ Some JDBC drivers support re-writing batched insert statements into multi-row in
- set JDBC driver specific connection parameter in **db.url** to enable the rewrite as shown in the examples below:
* MySQL [rewriteBatchedStatements=true](https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-configuration-properties.html) with `db.url=jdbc:mysql://127.0.0.1:3306/ycsb?rewriteBatchedStatements=true`
* Postgres [reWriteBatchedInserts=true](https://jdbc.postgresql.org/documentation/head/connect.html#connection-parameters) with `db.url=jdbc:postgresql://127.0.0.1:5432/ycsb?reWriteBatchedInserts=true`





5 changes: 4 additions & 1 deletion jdbc/src/main/java/com/yahoo/ycsb/db/JdbcDBClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ public void init() throws DBException {
}
int shardCount = 0;
conns = new ArrayList<Connection>(3);
final String[] urlArr = urls.split(",");
// for a longer explanation see the README.md
// semicolons aren't present in JDBC urls, so we use them to delimit
// multiple JDBC connections to shard across.
final String[] urlArr = urls.split(";");
busbey marked this conversation as resolved.
Show resolved Hide resolved
for (String url : urlArr) {
System.out.println("Adding shard node URL: " + url);
Connection conn = DriverManager.getConnection(url, user, passwd);
Expand Down