Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #37152
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Cecil Westerhof <Cecil@decebal.nl> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Is this a correct implementation of an abstract class and implementation class |
| Date | Sat, 12 Aug 2017 23:20:46 +0200 |
| Organization | Decebal Computing |
| Lines | 44 |
| Message-ID | <87r2wgxz2p.fsf@munus.decebal.nl> (permalink) |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Info | mx02.eternal-september.org; posting-host="a1c8c080b2cb6129343ef73ef98e693f"; logging-data="13865"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18MikaFQGiCJ5TlL1SyT8SxdbKy/xZ3HLo=" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
| X-Homepage | http://www.decebal.nl/ |
| Cancel-Lock | sha1:ca1zpNGw6/4RQRM7VLIysPYr5ZQ= sha1:tffo86J3az+4UFpKbiwhiHZGmQo= |
| Xref | csiph.com comp.lang.java.programmer:37152 |
Show key headers only | View raw
I want to write a layer around JDBC. For this I have an abstract class
SQL in which I have the following constructor and abstract methods:
// ################ constructors
public SQL (String database) throws SQLException {
String forName = getForName();
String sqlDriver = getSQLDriver();
try {
Class.forName(forName);
} catch (ClassNotFoundException e) {
throw new SQLException("Could not find the class " + forName + ".");
}
conn = DriverManager.getConnection(sqlDriver + database);
this.database = database;
}
// ################ abstract
abstract String getForName();
abstract String getSQLDriver();
I have also an implementation class SQLite3 in which I have:
// ################ constructors
public SQLite3 (String database) throws SQLException {
super(database);
}
// ################ default
@Override
String getForName() {
return "org.sqlite.JDBC";
}
@Override
String getSQLDriver() {
return "jdbc:sqlite:";
}
Is this the correct way to do this, or is there a better way?
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread
Is this a correct implementation of an abstract class and implementation class Cecil Westerhof <Cecil@decebal.nl> - 2017-08-12 23:20 +0200
Re: Is this a correct implementation of an abstract class and implementation class Arne Vajhøj <arne@vajhoej.dk> - 2017-08-12 22:00 -0400
Re: Is this a correct implementation of an abstract class and implementation class Cecil Westerhof <Cecil@decebal.nl> - 2017-08-13 07:14 +0200
Re: Is this a correct implementation of an abstract class and implementation class Andreas Leitgeb <avl@logic.at> - 2017-08-13 09:37 +0000
Re: Is this a correct implementation of an abstract class and implementation class Andreas Leitgeb <avl@logic.at> - 2017-08-13 10:13 +0000
Re: Is this a correct implementation of an abstract class and implementation class Arne Vajhøj <arne@vajhoej.dk> - 2017-08-13 16:27 -0400
Re: Is this a correct implementation of an abstract class and implementation class lewbloch@gmail.com - 2017-08-13 09:49 -0700
Re: Is this a correct implementation of an abstract class and implementation class Arne Vajhøj <arne@vajhoej.dk> - 2017-08-13 16:25 -0400
Re: Is this a correct implementation of an abstract class and implementation class Cecil Westerhof <Cecil@decebal.nl> - 2017-08-13 07:33 +0200
csiph-web