Interface EntityConnectionProvider

All Superinterfaces:
AutoCloseable
All Known Subinterfaces:
HttpEntityConnectionProvider, LocalEntityConnectionProvider, RemoteEntityConnectionProvider
All Known Implementing Classes:
AbstractEntityConnectionProvider

public interface EntityConnectionProvider extends AutoCloseable
Provides a managed EntityConnection instance with automatic reconnection handling.

EntityConnectionProvider serves as the primary entry point for database access in Codion applications. It manages connection lifecycle, handles reconnection for both local and remote connections, and provides a consistent interface regardless of the underlying connection type.

Connection Types

Basic Usage

 // Local connection
 EntityConnectionProvider provider = LocalEntityConnectionProvider.builder()
     .domainType(DOMAIN)
     .user(User.parse("scott:tiger"))
     .build();

 // Remote connection
 EntityConnectionProvider provider = RemoteEntityConnectionProvider.builder()
     .domainType(DOMAIN)
     .hostname("localhost")
     .port(2223)
     .registryPort(1099)
     .user(User.parse("scott:tiger"))
     .build();

 // Use the connection
 try (EntityConnectionProvider connProvider = provider) {
     EntityConnection connection = connProvider.connection();
     List<Entity> customers = connection.select(all(Customer.TYPE));
 }

Configuration-based Creation

 // Configure via system properties
 System.setProperty("codion.client.connectionType", "remote");

 // Create provider based on configuration
 EntityConnectionProvider provider = EntityConnectionProvider.builder()
     .user(User.parse("scott:tiger"))
     .build();
See Also: