Skip to content

caffetteria/data-service-db-simple

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

data-service-db-simple

Keep a Changelog v1.1.0 badge Maven Central license code of conduct Quality Gate Status Coverage

Java runtime version Java build version Apache Maven

Semplice implementazione di un Data Service Client che si basa su una tabella di un RDBMS

Quickstart

  1. Aggiungere dipendenza :
<dependency>
    <groupId>io.github.caffetteria</groupId>
    <artifactId>data-service-db-simple</artifactId>
    <version>${data-service-db-simple-version}</version>
</dependency>
  1. Create database schema
CREATE TABLE data_service_db_simple (
id BIGINT,
content BLOB,
primary key (ID)
);

CREATE SEQUENCE  data_service_db_simple_seq START WITH 1 INCREMENT BY 1;
  1. Configuration reference
parametero obbligatorio default note
db_mode false Possible values are : postgres, mysql, oracle, if not set will try to get from database metadata
table_id true data_service_db_simple Table id, with schema, catalog and so (ex. my_catalog.my_schema.my_table)
field_id true id Field to be used as id in the chosen table. Should be BIGINT
field_content true content Field to be used as content in the chosen table. Should be BLOB
sequence_id true data_service_db_simple_seq Name of the sequence to be used for id generation.

Sample configuration :

db_mode=oracle
table_id=data_service_db_simple
field_id=id
field_content=content
  1. Setup data service
ConnectionFactory cf = ...
Properties dsProps = ...
ConfigParams config = new ConfigParamsDefault( dsProps );
DbSimpleDataServiceFacade facade = new DbSimpleDataServiceFacade( cf, config );
DataService dataService = DbSimpleDataService.newDataService( facade );
String testData = "testData";
try (InputStream input = new ByteArrayInputStream(testData.getBytes())) {
    String id = dataService.save( input );
    String readData = StreamIO.readString( dataService.load( id ) );
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages