https://github.com/lucko/sql-streams
Painless low level jdbc abstraction using the java 8 stream api.
https://github.com/lucko/sql-streams
Last synced: 7 months ago
JSON representation
Painless low level jdbc abstraction using the java 8 stream api.
- Host: GitHub
- URL: https://github.com/lucko/sql-streams
- Owner: lucko
- License: mit
- Fork: true (bendem/sql-streams)
- Created: 2019-06-05T21:49:58.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-05T22:17:08.000Z (about 7 years ago)
- Last Synced: 2025-07-04T15:12:53.205Z (about 1 year ago)
- Language: Java
- Homepage:
- Size: 142 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## sql-streams
[](https://codeship.com/projects/149357)
`sql-streams` is a tool for the people that don't need or want to use an ORM but
don't want to deal with the [JDBC API] either. It provides a light abstraction
over JDBC without ever making it inaccessible.
## Features
+ Simple setup if you already have a `Connection` or a `DataSource` available
+ Fluent API
+ `ResultSet` is abstracted to a `Stream`
+ Classes that can be closed are `AutoCloseable`
+ `SQLException` are wrapped into `UncheckedSqlException`
+ Doesn't try to hide the JDBC primitives, they are never further than a method
call away
+ Automatic type deduction with the `with` method
## Getting started
To get started, all you need to do is to add `sql-streams` to your dependencies:
```xml
be.bendem
sql-streams
[current version]
```
```groovy
compile 'be.bendem:sql-streams:[current version]'
```
Once it is done, you can create an instance of `Sql` using one of the two
`connect` methods.
```java
try (Sql sql = Sql.connect(datasource)) {
Optional userEmail = sql
.first("select email from users where user_id = ?")
.with(userId);
}
```
If you are using spring-boot, checkout [sql-streams-spring]!
## Development
You will need [maven] to compile and install this library
```sh
mvn install
```
In addition to the SQLite and H2 tests, you can run the tests with PostgreSQL by providing a jdbc
connection url:
```sh
PGURL=jdbc:postgresql:test mvn test
# or with user and password if not using peer authentication
PGURL=jdbc:postgresql://localhost/test PGUSER=test PGPASSWORD=test mvn test
```
[ORM]: http://www.oracle.com/technetwork/java/javaee/tech/persistence-jsp-140049.html
[JDBC API]: https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/
[maven]: https://maven.apache.org/
[sql-streams-spring]: https://github.com/bendem/sql-streams-spring