Skip to content

Commit

Permalink
Easy to use try-with-resources, add README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
heshengbang committed Oct 6, 2018
1 parent c7be9b0 commit f653e62
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@ influxDB.dropRetentionPolicy(rpName, dbName);
influxDB.deleteDatabase(dbName);
```

#### Try-with-resources
Try-with-resources is a new feature in JDK7, InfluxDB support this feature, you can use it just like the following example:

```java
try (InfluxDB influxDB = InfluxDBFactory.connect("http://172.17.0.2:8086", "root", "root")) {
// Read or Write, do any thing you want
}
```

### Advanced Usage

#### Gzip's support (version 2.5+ required)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/influxdb/InfluxDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @author stefan.majer [at] gmail.com
*
*/
public interface InfluxDB {
public interface InfluxDB extends AutoCloseable {

/**
* The system property key to set the http logging level across the JVM.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/influxdb/impl/InfluxDBImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
*
* @author stefan.majer [at] gmail.com
*/
public class InfluxDBImpl implements InfluxDB, AutoCloseable {
public class InfluxDBImpl implements InfluxDB {

private static final String APPLICATION_MSGPACK = "application/x-msgpack";

Expand Down

0 comments on commit f653e62

Please sign in to comment.