How bh5k/javase17creationaldesignpatterns works
This small Java example demonstrates two singleton patterns: a lazily initialized database singleton that supplies a JDBC connection, and Java’s built-in Runtime singleton. The database demo uses the connection to create a table and insert a row; the everyday demo compares two Runtime references. The database behavior is visible in the sampled source; no README describes additional capabilities.
Main entry points: DbSingletonDemo.java Database Demo · DbSingleton.java Database Singleton · SingletonEverydayDemo.java Runtime Demo
Components 5
Other components
- Database Demo
src/main/java/com/pluralsight/singleton/DbSingletonDemo.java - Database Singleton
src/main/java/com/pluralsight/singleton/DbSingleton.java - H2 In-Memory DB
- Runtime Demo
src/main/java/com/pluralsight/singleton/SingletonEverydayDemo.java - Java Runtime
Connections 7
- Database Demo → Database Singleton: gets instance
- Database Singleton → Database Demo: returns instance
- Database Demo → Database Singleton: gets connection
- Database Singleton → H2 In-Memory DB: opens connection
- Database Demo → H2 In-Memory DB: executes SQL
- Runtime Demo → Java Runtime: gets singleton
- Runtime Demo → Java Runtime: requests garbage collection