Package org.spongepowered.api.sql
Interface SqlManager
public interface SqlManager
This manager provides the basics for an abstraction over SQL connections.
-
Method Summary
Modifier and TypeMethodDescriptionconnectionUrlFromAlias
(String alias) Returns a possible connection URL for a given alias.dataSource
(String jdbcConnection) Returns a data source for the provided JDBC connection string or an alias.dataSource
(org.spongepowered.plugin.PluginContainer plugin, String jdbcConnection) Returns a data source for the provided JDBC connection string or an alias.
-
Method Details
-
dataSource
Returns a data source for the provided JDBC connection string or an alias.A jdbc connection url is expected to be of the form: jdbc:<engine>://[<username>[:<password>]@]<host >/<database> or an alias (available aliases are known only by the service provider)
- Parameters:
jdbcConnection
- The jdbc url or connection alias- Returns:
- A data source providing connections to the given URL.
- Throws:
SQLException
- if a connection to the given database could not be established
-
dataSource
DataSource dataSource(org.spongepowered.plugin.PluginContainer plugin, String jdbcConnection) throws SQLException Returns a data source for the provided JDBC connection string or an alias.A jdbc connection url is expected to be of the form: jdbc:<engine>://[<username>[:<password>]@] <host>/<database> or an alias (available aliases are known only by the service provider)
- Parameters:
plugin
- The plugin to lookup databases relative to (primarily applying to file-backed databases)jdbcConnection
- The jdbc url or connection alias- Returns:
- A data source providing connections to the given URL.
- Throws:
SQLException
- if a connection to the given database could not be established
-
connectionUrlFromAlias
Returns a possible connection URL for a given alias.- Parameters:
alias
- The alias to check- Returns:
- The connection url as a String if it exists,
or
Optional.empty()
-