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 TypeMethodDescriptiongetConnection
(String host, String port, String dbName, String dbLogin, String dbPassword, String... addOnArgs) Provide and open the connection for the given arguments.Returns the class name of the database driver.getDriverUrl
(String host, String port, String dbName, String dbLogin, String dbPassword, String... addOnArgs) Constructs the driver's URL from the arguments.
-
Method Details
-
getConnection
Connection getConnection(String host, String port, String dbName, String dbLogin, String dbPassword, String... addOnArgs) throws SQLException Provide 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:
SQLException
- when the connection cannot be opened
-
getDbDriverClassName
String getDbDriverClassName()Returns the class name of the database driver. The method shall returnnull
in case of any errors.- Returns:
- the dbDriverClassName
- Since:
- 1.2.9
-
getDriverUrl
String getDriverUrl(String host, String port, String dbName, String dbLogin, String dbPassword, String... addOnArgs) Constructs the driver's URL from the arguments. The method shall returnnull
in 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
-