2828 * Abstract base class for JDBC database connectors.
2929 * Provides common functionality for establishing database connections.
3030 */
31- public abstract class AbstractJdbcConnector {
31+ public abstract class AbstractJdbcConnector implements IJdbcConnector {
32+
33+ private final String url ;
3234
3335 /**
34- * Creates a new database connection using the parameters specified in the constructor.
35- * The caller is responsible for closing the connection.
36- *
37- * @return new database connection
38- * @throws IOException if the driver is not found or a database access error occurs
36+ * @param url jdbc connection string
3937 */
38+ protected AbstractJdbcConnector (String url ) {
39+ this .url = url ;
40+ }
41+
42+ @ Override
4043 public Connection getConnection () throws IOException {
4144 try {
4245 loadDriver ();
@@ -55,10 +58,10 @@ protected void loadDriver() throws ClassNotFoundException {
5558 Class .forName (getDriverName ());
5659 }
5760
58- /**
59- * @return full connection string
60- */
61- protected abstract String getUrl ();
61+ @ Override
62+ public String getUrl () {
63+ return url ;
64+ }
6265
6366 /**
6467 * @return connection properties
@@ -75,16 +78,17 @@ protected Properties makeProperties() {
7578 protected abstract String getDriverName ();
7679
7780 /**
78- * Returns batch delimiter. If the value is null, each statement will be executed separately in autocommit mode.
79- *
80- * @return batch delimiter
81+ * @return default port
8182 */
82- public String getBatchDelimiter () {
83- return null ;
84- }
85-
86- protected abstract String getDefaultPort ();
83+ protected abstract int getDefaultPort ();
8784
85+ /**
86+ * Validates connection string
87+ *
88+ * @param url connection string
89+ * @param allowedPrefixes allowed prefixes
90+ * @throws IllegalArgumentException if the string does not start with the allowed prefixes
91+ */
8892 protected void validateUrl (String url , String ... allowedPrefixes ) {
8993 for (var prefix : allowedPrefixes ) {
9094 if (url .startsWith (prefix )) {
0 commit comments