[Rapforums-developer] src/source/edu/fullcoll/uportal/channels/rap/forum/database DatabaseNames.java
Status: Beta
Brought to you by:
brippe
Update of /cvsroot/rapforums/src/source/edu/fullcoll/uportal/channels/rap/forum/database In directory sc8-pr-cvs1:/tmp/cvs-serv17361/source/edu/fullcoll/uportal/channels/rap/forum/database Modified Files: DatabaseNames.java RAPDB.java RAPDBException.java RAPDBService.java database.dfPackage Log Message: no message Index: DatabaseNames.java =================================================================== RCS file: /cvsroot/rapforums/src/source/edu/fullcoll/uportal/channels/rap/forum/database/DatabaseNames.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** DatabaseNames.java 17 Sep 2003 19:54:01 -0000 1.1.1.1 --- DatabaseNames.java 25 Sep 2003 22:57:08 -0000 1.2 *************** *** 24,39 **** /** - * DatabaseNames - * * This interface provides access to database names used by * RAP Forums. * * @author Brad Rippe (br...@fu...) ! * @version 0.3 $Revision: */ public interface DatabaseNames { public final static String PORTAL_CHANNELS = "uPortalChannels"; public final static String PORTAL = "uPortal"; - public final static String USERS = "Vegas"; } --- 24,36 ---- /** * This interface provides access to database names used by * RAP Forums. * * @author Brad Rippe (br...@fu...) ! * @version 0.8.2 $Revision %G% */ public interface DatabaseNames { public final static String PORTAL_CHANNELS = "uPortalChannels"; public final static String PORTAL = "uPortal"; } Index: RAPDB.java =================================================================== RCS file: /cvsroot/rapforums/src/source/edu/fullcoll/uportal/channels/rap/forum/database/RAPDB.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** RAPDB.java 17 Sep 2003 19:54:01 -0000 1.1.1.1 --- RAPDB.java 25 Sep 2003 22:57:08 -0000 1.2 *************** *** 46,55 **** /** - * RAPDB - * * This class handles general database interaction for Rap forums. * * @author Brad Rippe (br...@fu...) ! * @version 0.3 $Revision: */ public class RAPDB extends RAPDBService { --- 46,53 ---- /** * This class handles general database interaction for Rap forums. * * @author Brad Rippe (br...@fu...) ! * @version 0.8.2 $Revision %G% */ public class RAPDB extends RAPDBService { Index: RAPDBException.java =================================================================== RCS file: /cvsroot/rapforums/src/source/edu/fullcoll/uportal/channels/rap/forum/database/RAPDBException.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** RAPDBException.java 17 Sep 2003 19:54:01 -0000 1.1.1.1 --- RAPDBException.java 25 Sep 2003 22:57:08 -0000 1.2 *************** *** 25,40 **** import edu.fullcoll.uportal.channels.rap.forum.RAPException; /** ! * RAPDBException ! * * This exception is thrown when there is an error with the database. * * @author Brad Rippe (br...@fu...) ! * @version 0.3 $Revision: */ public class RAPDBException extends RAPException { public RAPDBException(String msg) { super(msg); } public RAPDBException(String msg, Exception nested) { super(msg, nested); --- 25,50 ---- import edu.fullcoll.uportal.channels.rap.forum.RAPException; /** ! * This exception is thrown when there is an error with the database. * * @author Brad Rippe (br...@fu...) ! * @version 0.8.2 $Revision %G% */ public class RAPDBException extends RAPException { + + /** + * Constructs a Database exception with the specified message + * @param msg - the exception's message + */ public RAPDBException(String msg) { super(msg); } + /** + * Constructs a database exception with the exception message + * and a nested exception. + * @param msg - the exception message + * @param nested - the initial exception + */ public RAPDBException(String msg, Exception nested) { super(msg, nested); Index: RAPDBService.java =================================================================== RCS file: /cvsroot/rapforums/src/source/edu/fullcoll/uportal/channels/rap/forum/database/RAPDBService.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** RAPDBService.java 17 Sep 2003 19:54:01 -0000 1.1.1.1 --- RAPDBService.java 25 Sep 2003 22:57:08 -0000 1.2 *************** *** 30,44 **** /** - * RAPDBService - * * This class provides basic functionality for RAP database classes. ! * RAPDBService uses Pool Man connection pooling. * * @author Brad Rippe (br...@fu...) ! * @version 0.3 $Revision: */ public abstract class RAPDBService { protected Connection dbConnection = null; /** --- 30,50 ---- /** * This class provides basic functionality for RAP database classes. ! * RAPDBService uses jndi lookup to obtain the data sources. * * @author Brad Rippe (br...@fu...) ! * @version 0.8.2 $Revision %G% */ public abstract class RAPDBService { protected Connection dbConnection = null; + private String defaultDSName = DatabaseNames.PORTAL; + + /** + * Constructs a RAPDBService object + */ + public RAPDBService() { + getChannelDSConfig(); + } /** *************** *** 50,54 **** Context envCtx = (Context) initCtx.lookup("java:comp/env/"); ! DataSource ds = (DataSource)envCtx.lookup("jdbc/"+DatabaseNames.PORTAL_CHANNELS); if (ds != null) --- 56,60 ---- Context envCtx = (Context) initCtx.lookup("java:comp/env/"); ! DataSource ds = (DataSource)envCtx.lookup("jdbc/"+defaultDSName); if (ds != null) *************** *** 57,61 **** if(dbConnection == null) { LogService.instance().log(LogService.ERROR, "Database connection error datasource null"); ! throw new RAPDBException("Database connection error: "+DatabaseNames.PORTAL_CHANNELS); } --- 63,67 ---- if(dbConnection == null) { LogService.instance().log(LogService.ERROR, "Database connection error datasource null"); ! throw new RAPDBException("Database connection error: "+defaultDSName); } *************** *** 80,84 **** DataSource ds = (DataSource)envCtx.lookup("jdbc/"+dbName); - //DataSource ds = PoolMan.findDataSource(dbName); if (ds != null) --- 86,89 ---- *************** *** 99,102 **** --- 104,111 ---- } + /** + * This method releases a Connection object's database and JDBC resources immediately. + * @throws RAPDBException - if a database error occurs + */ protected void closeConnection() throws RAPDBException { try { *************** *** 114,117 **** --- 123,130 ---- } + /** + * Releases the specified ResultSet object's database and JDBC resources. + * @throws RAPDBException - if a database error occurs + */ protected void closeResultSet(ResultSet result) throws RAPDBException { try { *************** *** 127,130 **** --- 140,147 ---- } + /** + * Releases the specified Statement object's database and JDBC resources. + * @throws RAPDBException - if a database error occurs + */ protected void closeStatement(Statement stmt) throws RAPDBException { try { *************** *** 137,140 **** --- 154,172 ---- throw new RAPDBException("SQL Exception while closing " + "Statement : \n" + se); + } + } + + /** + * This method determines if the forums have been configured two use multiple + * databases. One scenario is to have one database for the portal data and one + * for the portal channels. If set to true, the forums expect to a data source + * called "uPortalChannels", otherwise the forums use a data source called "uPortal". + * @param separateDB - true if the forums are configured to use two databases, otherwise false + */ + private void getChannelDSConfig() { + if(RAPDBConfig.getInstance().isMultiDS()) { + defaultDSName = DatabaseNames.PORTAL_CHANNELS; + } else { + defaultDSName = DatabaseNames.PORTAL; } } Index: database.dfPackage =================================================================== RCS file: /cvsroot/rapforums/src/source/edu/fullcoll/uportal/channels/rap/forum/database/database.dfPackage,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** database.dfPackage 17 Sep 2003 19:54:01 -0000 1.1.1.1 --- database.dfPackage 25 Sep 2003 22:57:08 -0000 1.2 *************** *** 7,11 **** */ class diagram { ! }/** @__tags @shapeType ClassDiagram --- 7,16 ---- */ class diagram { ! /** ! @__ref <oiref:java#Class#edu.fullcoll.uportal.channels.rap.forum.database.RAPDBConfig:oiref><oihard> ! @__modelType reference ! */ ! class reference { ! }}/** @__tags @shapeType ClassDiagram |