Hi, Spring fans! In this installment, we'll look at how to build tenancy-aware JDBC applications

Overview

Multitenant JDBC

You'll need to spin up two separate PostgreSQL instances. Put this script into a file called postgres.sh:

#!/usr/bin/env bash
NAME=${1:-default}-postgres
PORT=${2:-5432}
docker run -d  --name  $NAME  \
    -p ${PORT}:5432 \
    -e POSTGRES_USER=user \
    -e PGUSER=user \
    -e POSTGRES_PASSWORD=pw \
postgres:latest

Don't forget to make it executable if you're on a UNIX flavor OS:

chmod a+x ./postgres.sh

Then, run it twice to spin up two different Docker images:

./postgres.sh pg1 5431 
./postgres.sh pg2 5432

Then, you can run the application. You should be able to login and observe that there are different datasets in each one.

You can login to each instance like this:

PGPASSWORD=pw psql -U user -h localhost -p 5431 user 

This program will write some sample data into each DataSource and make it available at http://localhost:8080/customers. You'll need to authenticate when you make the request using HTTP BASIC authentication. For example:

curl -U jlong:pw http://localhost:8080/customers
You might also like...

Apache Ant is a Java-based build tool.

Apache Ant What is it? ----------- Ant is a Java based build tool. In theory it is kind of like "make" without makes wrinkles and with

Dec 22, 2022

The application is a PoC that helps in identifying modern bankers, potentially malicious and remote controlling applications abusing Android AccessibilityService.

Motivation Project aims to help in: identifying keyloggers and events hijacking malicious applications such as Anubis/TeaBot, identifying a "fake bank

Dec 9, 2022

ESA Cabin is a lightweight class isolation container for Java applications.

ESA Cabin is a lightweight class isolation container for Java applications.

Cabin Cabin是一款Java类隔离框架,用于隔离各个模块之间、模块和业务之间使用的第三方依赖库。使用Cabin后,模块SDK将只是用自己指定 版本的三方依赖,不会被业务引入的依赖所影响,保证业务正常运行,提高业务的开发效率,减少中间件同学此类重复的支持工作。 概述 ESA Cabin用于解决

Dec 1, 2022

HRMS Project Java Spring Boot

HRMS Project Java Spring Boot

Controllers Employees Controller getAll getById getByEmail getByIdentityNo save Employers Controller getAll getById getByEmail save Personnels Control

Jun 19, 2022

Dcl372-2022-jan-04 - DCL-372: Core Spring 5

Dcl372-2022-jan-04 - DCL-372: Core Spring 5

DCL-372: Core Spring 5 These projects are created as part of the following training: DCL-372 "Core Spring 5" Please follow the link for the complete t

Jan 10, 2022

Hi, Spring fans! In this installment, we're going to look at some the C in M-V-C and their representation in Spring's `@Controller` types!

@Controllers Hi, Spring fans! In this installment, we're going to look at some the C in M-V-C and their representation in Spring's @Controller types!

Nov 19, 2022

Hi, Spring fans! In this installment we look Spring Integration's support for MQTT and the HiveMQ broker

Spring Integration MQTT & HiveMQ Hi, Spring fans! In this installment we look Spring Integration's support for MQTT and the HiveMQ broker. I'm joined

Nov 21, 2022

Hi, Spring fans! We're going to learn how to build Kubernetes operators, CRDs, and controllers

Bootiful Kubernetes Operators Make sure youre in the default namespace of a Kubernetes cluster. Not sure fi this matters but I am, so it might help. T

Dec 29, 2022

esProc SPL is a scripting language for data processing, with well-designed rich library functions and powerful syntax, which can be executed in a Java program through JDBC interface and computing independently.

esProc SPL is a scripting language for data processing, with well-designed rich library functions and powerful syntax, which can be executed in a Java program through JDBC interface and computing independently.

esProc esProc is the unique name for esProc SPL package. esProc SPL is an open-source programming language for data processing, which can perform comp

Dec 27, 2022

Lifecycle-aware shared observable data holder class for android.

Lifecycle-aware shared observable data holder class for android.

Eyejet Lifecycle-aware shared observable data holder class for android. 1. Depend on our library Eyejet Library is available through Maven Repository.

Jul 27, 2021

Spring Boot JdbcTemplate example with SQL Server: CRUD Rest API using Spring Data JDBC, Spring Web MVC

Spring Boot JdbcTemplate example with SQL Server: Build CRUD Rest API Build a Spring Boot CRUD Rest API example that uses Spring Data Jdbc to make CRU

Dec 20, 2022

OpenMap is an Open Source JavaBeans-based programmer's toolkit. Using OpenMap, you can quickly build applications and applets that access data from legacy databases and applications.

$Source: /cvs/distapps/openmap/README,v $ $RCSfile: README,v $ $Revision: 1.11 $ $Date: 2002/11/06 19:11:02 $ $Author: bmackiew $ OpenMap(tm) What

Nov 12, 2022

Spoon is a metaprogramming library to analyze and transform Java source code (up to Java 15). :spoon: is made with :heart:, :beers: and :sparkles:. It parses source files to build a well-designed AST with powerful analysis and transformation API.

Spoon Spoon is an open-source library to analyze, rewrite, transform, transpile Java source code. It parses source files to build a well-designed AST

Dec 29, 2022

循序渐进,学习Spring Boot、Spring Boot & Shiro、Spring Batch、Spring Cloud、Spring Cloud Alibaba、Spring Security & Spring Security OAuth2,博客Spring系列源码:https://mrbird.cc

Spring 系列教程 该仓库为个人博客https://mrbird.cc中Spring系列源码,包含Spring Boot、Spring Boot & Shiro、Spring Cloud,Spring Boot & Spring Security & Spring Security OAuth2

Jan 6, 2023

Spring Integration provides an extension of the Spring programming model to support the well-known Enterprise Integration Patterns (EIP)

Spring Integration Code of Conduct Please see our Code of conduct. Reporting Security Vulnerabilities Please see our Security policy. Checking out and

Dec 30, 2022

SpotBugs is FindBugs' successor. A tool for static analysis to look for bugs in Java code.

SpotBugs is FindBugs' successor. A tool for static analysis to look for bugs in Java code.

SpotBugs is the spiritual successor of FindBugs, carrying on from the point where it left off with support of its community. SpotBugs is licensed unde

Jan 4, 2023

This mod makes the clouds look much better.

This mod makes the clouds look much better.

Fabulous Clouds is a 1.17 Fabric mod that makes minecraft's clouds look much better. It isn't going to be ported to Forge or be backported. Fabulous C

Oct 28, 2022

This is library that look like Scarlet Wrapper Socket.io

This is library that look like Scarlet Wrapper Socket.io

Jan 2, 2023
Owner
Spring Tips
Find all the code associated with my Spring Tips series on YouTube
Spring Tips
SPRING MySQL Database Connection using JDBC STEPS

SPRING-MySQL-Database-Connection-using-JDBC-STEPS SPRING MySQL Database Connection using JDBC STEPS Step1: Create maven project Group id: com.cdac Art

Dnyaneshwar Madhewad 1 Jan 27, 2022
光 HikariCP・A solid, high-performance, JDBC connection pool at last.

HikariCP It's Faster.Hi·ka·ri [hi·ka·'lē] (Origin: Japanese): light; ray. Fast, simple, reliable. HikariCP is a "zero-overhead" production ready JDBC

Brett Wooldridge 17.7k Jan 1, 2023
Vibur DBCP - concurrent and dynamic JDBC connection pool

Vibur DBCP is concurrent, fast, and fully-featured JDBC connection pool, which provides advanced performance monitoring capabilities, including slow S

Vibur 94 Apr 20, 2022
JDBC driver for ClickHouse

This is a basic and restricted implementation of jdbc driver for ClickHouse. It has support of a minimal subset of features to be usable.

ClickHouse 1.1k Jan 1, 2023
Multi-DBMS SQL Benchmarking Framework via JDBC

BenchBase BenchBase (formerly OLTPBench) is a Multi-DBMS SQL Benchmarking Framework via JDBC. Table of Contents Quickstart Description Usage Guide Con

CMU Database Group 213 Dec 29, 2022
Provides many useful CRUD, Pagination, Sorting operations with Thread-safe Singleton support through the native JDBC API.

BangMapleJDBCRepository Inspired by the JpaRepository of Spring framework which also provides many capabilities for the CRUD, Pagination and Sorting o

Ngô Nguyên Bằng 5 Apr 7, 2022
Core ORMLite functionality that provides a lite Java ORM in conjunction with ormlite-jdbc or ormlite-android

ORMLite Core This package provides the core functionality for the JDBC and Android packages. Users that are connecting to SQL databases via JDBC shoul

Gray 547 Dec 25, 2022
Amazon AppFlow Custom JDBC Connector example

Amazon AppFlow Custom JDBC Connector example This project contains source code and supporting files that implements Amazon Custom Connector SDK and re

AWS Samples 6 Oct 26, 2022
Online Quiz system - JDBC, JSP

Online-Quiz-System-in-Java Online Quiz system - JDBC, JSP Java Project based on JDBC, JSP, Java Servlet and Server Deployment Project Aim Develop web

Muhammad Asad 6 Oct 14, 2022
A JDBC driver for Cloudflare's D1 product, compatible with Jetbrains tools.

D1 JDBC Driver A JDBC driver for Cloudflare's D1 Database product! JDBC is the technology that drives popular database tools such as Jetbrains' databa

Isaac McFadyen 21 Dec 9, 2022