Package rs.baselib.sql
Interface IJdbcConnectionProvider
- All Known Subinterfaces:
IJdbcConnectionProvider2
- All Known Implementing Classes:
AbstractJdbcConnectionProvider,HyperSqlFileJdbcConnectionProvider,HyperSqlServerJdbcConnectionProvider,MySql5JdbcConnectionProvider
public interface IJdbcConnectionProvider
An interface for generically providing JDBC connections.
The intention of this interface is to encapsulate all database
specific issues of constructing a URL or the driver name.
Clients of IJdbcConnectionProvider simply call
getConnection(String, String, String, String, String, String...) in order
to get a valid driver URL constructed and passed to DriverManager.
- Author:
- ralph
-
Method Summary
Modifier and Type Method Description java.sql.ConnectiongetConnection(java.lang.String host, java.lang.String port, java.lang.String dbName, java.lang.String dbLogin, java.lang.String dbPassword, java.lang.String... addOnArgs)Provide and open the connection for the given arguments.java.lang.StringgetDbDriverClassName()Returns the class name of the database driver.java.lang.StringgetDriverUrl(java.lang.String host, java.lang.String port, java.lang.String dbName, java.lang.String dbLogin, java.lang.String dbPassword, java.lang.String... addOnArgs)Constructs the driver's URL from the arguments.
-
Method Details
-
getConnection
java.sql.Connection getConnection(java.lang.String host, java.lang.String port, java.lang.String dbName, java.lang.String dbLogin, java.lang.String dbPassword, java.lang.String... addOnArgs) throws java.sql.SQLExceptionProvide and open the connection for the given arguments.- Parameters:
host- the host of the databaseport- the port of the database (some DB use names as port information)dbName- name of databasedbLogin- database logindbPassword- database passwordaddOnArgs- additional arguments to be processed by the driver- Returns:
- an opened connection if successful
- Throws:
java.sql.SQLException- when the connection cannot be opened
-
getDbDriverClassName
java.lang.String getDbDriverClassName()Returns the class name of the database driver. The method shall returnnullin case of any errors.- Returns:
- the dbDriverClassName
- Since:
- 1.2.9
-
getDriverUrl
java.lang.String getDriverUrl(java.lang.String host, java.lang.String port, java.lang.String dbName, java.lang.String dbLogin, java.lang.String dbPassword, java.lang.String... addOnArgs)Constructs the driver's URL from the arguments. The method shall returnnullin case of any problems or throw an exception.- Parameters:
host- the host of the databaseport- the port of the database (some DB use names as port information)dbName- name of databasedbLogin- database logindbPassword- database passwordaddOnArgs- additional arguments for the driver URL- Returns:
- the URL for the driver or
null
-