Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

rdbc-io/rdbc-examples

Repository files navigation

Travis Gitter license

This repository

This repository contains a collection of example projects using rdbc database connectivity API. Chapters below describe the implemented examples.

Examples

Simple

You can find the code of this example in simple-java directory. As the name suggest it's just a simple piece of code implemented in Java that inserts a couple of records and queries them afterwards.

The projects use the API with the PostgreSQL driver. Before you run the project, start PostgreSQL server on the local machine and configure it to accept connections with password authentication method using "postgres" username and "postgres" password.

To run the project, enter the rdbc-examples directory and start the application with SBT using sbt simple-java/run.

Play Framework

You can find a Scala version of the example in play-scala directory and Java version in
play-java.

The projects use the API with the PostgreSQL driver. Before you run the project, start PostgreSQL server on the local machine and configure it to accept connections with password authentication method using "postgres" username and "postgres" password. Alternatively, configure connection parameters in conf/application.conf file.

To run the project, enter the rdbc-examples directory and start the application with SBT using sbt play-scala/run or sbt play-java/run command. After starting the app, a sample database table will be created.

The application defines a number of routes:

  • /list - a HTML page allowing you to add and list records defined in the sample table.
  • /stream - endpoint streaming table contents as JSONs.

See Module class (Scala, Java) for the code that configures connection pool and creates a sample table. Inspect ApplicationController (Scala, Java) class for the implementation of selecting and inserting values and also for the streaming. It may be interesting for you to add many records to the table, say, 100 000 and compare behavior of the application when:

  • requesting the data with streaming: wget http://localhost:9000/stream
  • requesting the data with no streaming: wget http://localhost:9000/list

Requesting the data with no streaming is likely to cause OutOfMemoryError and force you to kill the application.

Releases

No releases published

Packages

No packages published