Skip to content

Commit 7307c8f

Browse files
committed
Documentation and examples
1 parent 609e693 commit 7307c8f

File tree

2 files changed

+50
-7
lines changed

2 files changed

+50
-7
lines changed

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Pg-async-driver is a non-blocking Java driver for PostgreSQL. The driver supports connection pooling, prepared statements, transactions and all standard SQL types.
44

5+
## Download
6+
57
Pg-async-driver is available on [Maven Central](http://search.maven.org/#search|ga|1|g%3A%22com.github.alaisi.pgasync%22).
68

79
```xml
@@ -42,9 +44,28 @@ pool.query("SELECT 'Hello world!' AS message",
4244

4345
### Connection pools
4446

47+
Connection pools are created with [`com.github.pgasync.ConnectionPoolBuilder`](https://github.com/alaisi/pg-async-driver/blob/master/src/main/java/com/github/pgasync/ConnectionPoolBuilder.java)
48+
49+
```java
50+
ConnectionPool pool = return new ConnectionPoolBuilder()
51+
.database("db")
52+
.username("user")
53+
.password("pass")
54+
.poolSize(20)
55+
.build();
56+
```
57+
58+
Each connection pool will start one IO thread used in communicating with PostgreSQL backend.
59+
60+
### Prepared statements
61+
62+
TODO
63+
64+
### Transactions
65+
4566
TODO
4667

4768
## References
4869
* [Scala postgresql-async](https://raw.github.com/mauricio/postgresql-async)
49-
* [PostgreSQL JDBC Driver](http://jdbc.postgresql.org)
70+
* [PostgreSQL JDBC Driver](http://jdbc.postgresql.org/about/about.html)
5071

src/main/java/com/github/pgasync/ConnectionPoolBuilder.java

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,36 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
115
package com.github.pgasync;
216

317
import com.github.pgasync.impl.netty.NettyPgConnectionPool;
418

519
/**
6-
* Builder
20+
* Builder for creating {@link ConnectionPool} instances.
21+
*
22+
* @author Antti Laisi
723
*/
824
public class ConnectionPoolBuilder {
925

10-
PoolProperties properties = new PoolProperties();
26+
final PoolProperties properties = new PoolProperties();
27+
28+
/**
29+
* @return Pool ready for use
30+
*/
31+
public ConnectionPool build() {
32+
return new NettyPgConnectionPool(properties);
33+
}
1134

1235
public ConnectionPoolBuilder hostname(String hostname) {
1336
properties.setHostname(hostname);
@@ -39,10 +62,9 @@ public ConnectionPoolBuilder poolSize(int poolSize) {
3962
return this;
4063
}
4164

42-
public ConnectionPool build() {
43-
return new NettyPgConnectionPool(properties);
44-
}
45-
65+
/**
66+
* Configuration for a pool.
67+
*/
4668
public static class PoolProperties {
4769

4870
String hostname = "localhost";

0 commit comments

Comments
 (0)