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 java.util.Optional<java.lang.String>connectionUrlFromAlias(java.lang.String alias)Returns a possible connection URL for a given alias.javax.sql.DataSourcedataSource(java.lang.String jdbcConnection)Returns a data source for the provided JDBC connection string or an alias.javax.sql.DataSourcedataSource(org.spongepowered.plugin.PluginContainer plugin, java.lang.String jdbcConnection)Returns a data source for the provided JDBC connection string or an alias.
-
-
-
Method Detail
-
dataSource
javax.sql.DataSource dataSource(java.lang.String jdbcConnection) throws java.sql.SQLExceptionReturns 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:
java.sql.SQLException- if a connection to the given database could not be established
-
dataSource
javax.sql.DataSource dataSource(org.spongepowered.plugin.PluginContainer plugin, java.lang.String jdbcConnection) throws java.sql.SQLExceptionReturns 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:
java.sql.SQLException- if a connection to the given database could not be established
-
connectionUrlFromAlias
java.util.Optional<java.lang.String> connectionUrlFromAlias(java.lang.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()
-
-