Package org.spongepowered.api.sql
Interface SqlManager
-
public interface SqlManagerThis manager provides the basics for an abstraction over SQL connections.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Optional<String>connectionUrlFromAlias(String alias)Returns a possible connection URL for a given alias.DataSourcedataSource(String jdbcConnection)Returns a data source for the provided JDBC connection string or an alias.DataSourcedataSource(org.spongepowered.plugin.PluginContainer plugin, String jdbcConnection)Returns a data source for the provided JDBC connection string or an alias.
-
-
-
Method Detail
-
dataSource
DataSource dataSource(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:
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
Optional<String> connectionUrlFromAlias(String alias)
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()
-
-