Class DataSourceService
java.lang.Object
io.micronaut.controlpanel.panels.datasource.DataSourceService
Service for a specific
DataSource, providing metadata about tables, columns, keys, etc.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordMetadata for a query result column.static final recordResult of executing a SQL query. -
Constructor Summary
ConstructorsConstructorDescriptionDataSourceService(DataSource dataSource) DataSourceService(DataSource dataSource, List<io.micronaut.controlpanel.panels.datasource.ConnectionPoolInspector> connectionPoolInspectors) -
Method Summary
Modifier and TypeMethodDescriptionexecuteQuery(String sql, int start, int length) Sanitize, execute and paginate a SQL query.generateMermaidER(List<Table> tables) Generate a Mermaid ER diagram for the current datasource based on the provided tables metadata.Retrieves JDBC product and driver metadata for the datasource.Retrieves connection pool metadata when the datasource uses a supported pool provider.Retrieves a list of tables from the database, including schema, columns, primary keys, and foreign keys.
-
Constructor Details
-
DataSourceService
@Inject public DataSourceService(@Parameter DataSource dataSource, List<io.micronaut.controlpanel.panels.datasource.ConnectionPoolInspector> connectionPoolInspectors) -
DataSourceService
-
-
Method Details
-
getJdbcInfo
Retrieves JDBC product and driver metadata for the datasource.- Returns:
- JDBC metadata, or an empty metadata object if it cannot be read
-
getPoolInfo
-
getTables
-
generateMermaidER
Generate a Mermaid ER diagram for the current datasource based on the provided tables metadata. It includes entities with attributes (type, size, NOT NULL) and relationships based on foreign keys.- Parameters:
tables- Tables discovered bygetTables()- Returns:
- Mermaid ER diagram code
-
executeQuery
Sanitize, execute and paginate a SQL query.- Parameters:
sql- The SQL to executestart- Offset of the first rowlength- Maximum number of rows to return- Returns:
- QueryResult with column labels, rows and total row count
-