[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model/db AbstractDatabase.java,1.1,1.2 Data
Status: Pre-Alpha
Brought to you by:
henryml
From: Jesper P. <je...@us...> - 2005-08-19 09:48:01
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/db In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11826/src/net/sourceforge/bprocessor/model/db Modified Files: AbstractDatabase.java Database.java DatabaseFactory.java HSQLDB.java PostgreSQL.java Log Message: Added isEnabled() Index: AbstractDatabase.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/db/AbstractDatabase.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AbstractDatabase.java 4 Aug 2005 06:04:43 -0000 1.1 --- AbstractDatabase.java 19 Aug 2005 09:47:52 -0000 1.2 *************** *** 117,119 **** --- 117,125 ---- */ public abstract int getType(); + + /** + * Is the database enabled ? + * @return True if enabled; otherwise false + */ + public abstract boolean isEnabled(); } Index: PostgreSQL.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/db/PostgreSQL.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PostgreSQL.java 4 Aug 2005 06:04:43 -0000 1.1 --- PostgreSQL.java 19 Aug 2005 09:47:52 -0000 1.2 *************** *** 52,54 **** --- 52,68 ---- return Database.POSTGRESQL; } + + /** + * Is the database enabled ? + * @return True if enabled; otherwise false + */ + public boolean isEnabled() { + try { + Class c = Thread.currentThread().getContextClassLoader().loadClass("org.postgresql.Driver"); + return true; + } catch (Exception e) { + // Ok + } + return false; + } } Index: HSQLDB.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/db/HSQLDB.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HSQLDB.java 4 Aug 2005 06:04:43 -0000 1.1 --- HSQLDB.java 19 Aug 2005 09:47:52 -0000 1.2 *************** *** 52,54 **** --- 52,68 ---- return Database.HSQLDB; } + + /** + * Is the database enabled ? + * @return True if enabled; otherwise false + */ + public boolean isEnabled() { + try { + Class c = Thread.currentThread().getContextClassLoader().loadClass("org.hsqldb.jdbcDriver"); + return true; + } catch (Exception e) { + // Ok + } + return false; + } } Index: Database.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/db/Database.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Database.java 4 Aug 2005 06:04:43 -0000 1.1 --- Database.java 19 Aug 2005 09:47:52 -0000 1.2 *************** *** 31,34 **** --- 31,40 ---- /** + * Is the database enabled ? + * @return True if enabled; otherwise false + */ + public boolean isEnabled(); + + /** * Get the url * @return The url of the database Index: DatabaseFactory.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/db/DatabaseFactory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DatabaseFactory.java 4 Aug 2005 09:51:33 -0000 1.2 --- DatabaseFactory.java 19 Aug 2005 09:47:52 -0000 1.3 *************** *** 70,74 **** known = false; } ! if (known) { database.setUrl(url); database.setUser(user); --- 70,74 ---- known = false; } ! if (known && database.isEnabled()) { database.setUrl(url); database.setUser(user); |