[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.sourceforge.net:/tmp/cvs-serv22259 Modified Files: DatabaseNames.java RAPDB.java RAPDBException.java RAPDBService.java Log Message: Update to version 0.8.3 Index: DatabaseNames.java =================================================================== RCS file: /cvsroot/rapforums/src/source/edu/fullcoll/uportal/channels/rap/forum/database/DatabaseNames.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DatabaseNames.java 25 Sep 2003 22:57:08 -0000 1.2 --- DatabaseNames.java 26 Jan 2004 18:55:50 -0000 1.3 *************** *** 1,4 **** /** ! * Copyright (C) 2003, Fullerton College. All Rights Reserved. * (http://www.fullcoll.edu) * --- 1,4 ---- /** ! * Copyright (c) 2004, Fullerton College. All Rights Reserved. * (http://www.fullcoll.edu) * *************** *** 18,22 **** * This software is OSI Certified Open Source Software. * OSI Certified is a certification mark of the Open Source Initiative ! * */ --- 18,22 ---- * This software is OSI Certified Open Source Software. * OSI Certified is a certification mark of the Open Source Initiative ! * */ *************** *** 28,36 **** * * @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"; } --- 28,36 ---- * * @author Brad Rippe (br...@fu...) ! * @version 0.8.3 $Revision %G% */ public interface DatabaseNames { public final static String PORTAL_CHANNELS = "uPortalChannels"; ! public final static String PORTAL = "PortalDb"; } Index: RAPDB.java =================================================================== RCS file: /cvsroot/rapforums/src/source/edu/fullcoll/uportal/channels/rap/forum/database/RAPDB.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RAPDB.java 25 Sep 2003 22:57:08 -0000 1.2 --- RAPDB.java 26 Jan 2004 18:55:50 -0000 1.3 *************** *** 1,4 **** /** ! * Copyright (C) 2003, Fullerton College. All Rights Reserved. * (http://www.fullcoll.edu) * --- 1,4 ---- /** ! * Copyright (c) 2004, Fullerton College. All Rights Reserved. * (http://www.fullcoll.edu) * *************** [...1889 lines suppressed...] ! ResultSet.TYPE_SCROLL_INSENSITIVE, ! ResultSet.CONCUR_READ_ONLY); stmt.setInt(1, catID); *************** *** 1361,1367 **** // returns the actual connection to its pool: closeStatement(stmt); ! closeConnection(); } } - } --- 1445,1450 ---- // returns the actual connection to its pool: closeStatement(stmt); ! closeConnection(dbConnection); } } } Index: RAPDBException.java =================================================================== RCS file: /cvsroot/rapforums/src/source/edu/fullcoll/uportal/channels/rap/forum/database/RAPDBException.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RAPDBException.java 25 Sep 2003 22:57:08 -0000 1.2 --- RAPDBException.java 26 Jan 2004 18:55:50 -0000 1.3 *************** *** 1,4 **** /** ! * Copyright (C) 2003, Fullerton College. All Rights Reserved. * (http://www.fullcoll.edu) * --- 1,4 ---- /** ! * Copyright (c) 2004, Fullerton College. All Rights Reserved. * (http://www.fullcoll.edu) * *************** *** 29,33 **** * * @author Brad Rippe (br...@fu...) ! * @version 0.8.2 $Revision %G% */ public class RAPDBException extends RAPException { --- 29,33 ---- * * @author Brad Rippe (br...@fu...) ! * @version 0.8.3 $Revision %G% */ public class RAPDBException extends RAPException { Index: RAPDBService.java =================================================================== RCS file: /cvsroot/rapforums/src/source/edu/fullcoll/uportal/channels/rap/forum/database/RAPDBService.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RAPDBService.java 25 Sep 2003 22:57:08 -0000 1.2 --- RAPDBService.java 26 Jan 2004 18:55:50 -0000 1.3 *************** *** 1,4 **** /** ! * Copyright (C) 2003, Fullerton College. All Rights Reserved. * (http://www.fullcoll.edu) * --- 1,4 ---- /** ! * Copyright (c) 2004, Fullerton College. All Rights Reserved. * (http://www.fullcoll.edu) * *************** *** 23,42 **** package edu.fullcoll.uportal.channels.rap.forum.database; ! import java.sql.*; ! import javax.sql.*; ! import javax.naming.*; import org.jasig.portal.services.LogService; /** * 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; --- 23,45 ---- package edu.fullcoll.uportal.channels.rap.forum.database; ! import java.sql.Connection; ! import java.sql.Statement; ! import java.sql.ResultSet; ! import java.sql.SQLException; + import org.jasig.portal.RDBMServices; import org.jasig.portal.services.LogService; /** * This class provides basic functionality for RAP database classes. ! * RAPDBService uses org.jasig.portal.RDBMServices to obtain a database connnection. * * @author Brad Rippe (br...@fu...) ! * @version 0.8.3 $Revision %G% ! * @see org.jasig.portal.RDBMServices ! * @see edu.fullcoll.uportal.channels.rap.forum.database.RAPDBConfig */ public abstract class RAPDBService { private String defaultDSName = DatabaseNames.PORTAL; *************** *** 51,76 **** * This method makes a database connection. */ ! protected void getDBConnection() throws RAPDBException { ! try { ! Context initCtx = new InitialContext(); ! Context envCtx = (Context) initCtx.lookup("java:comp/env/"); ! ! DataSource ds = (DataSource)envCtx.lookup("jdbc/"+defaultDSName); ! ! if (ds != null) ! dbConnection = ds.getConnection(); ! ! if(dbConnection == null) { ! LogService.instance().log(LogService.ERROR, "Database connection error datasource null"); ! throw new RAPDBException("Database connection error: "+defaultDSName); ! } ! ! } catch(SQLException e) { ! LogService.instance().log(LogService.ERROR, "Database connection error " + e); ! throw new RAPDBException("Database connection error", e); ! } catch(NamingException e2) { ! LogService.instance().log(LogService.ERROR, "Database connection error " + e2); ! throw new RAPDBException("Database connection error", e2); ! } } --- 54,59 ---- * This method makes a database connection. */ ! protected Connection getDBConnection() throws RAPDBException { ! return RDBMServices.getConnection(defaultDSName); } *************** *** 78,105 **** * This method makes a database connection to the specified database. * @param dbName the name of the database to connect to. ! * @see edu.fullcoll.uportal.channels.rap.database.DatabaseNames */ ! protected void getDBConnection(String dbName) throws RAPDBException { ! try { ! Context initCtx = new InitialContext(); ! Context envCtx = (Context) initCtx.lookup("java:comp/env/"); ! ! DataSource ds = (DataSource)envCtx.lookup("jdbc/"+dbName); ! ! if (ds != null) ! dbConnection = ds.getConnection(); ! ! if(dbConnection == null) { ! LogService.instance().log(LogService.ERROR, "Database connection error datasource null"); ! throw new RAPDBException("Database connection error: "+dbName); ! } ! ! } catch(SQLException e) { ! LogService.instance().log(LogService.ERROR, "Database connection error " + e); ! throw new RAPDBException("Database connection error", e); ! } catch(NamingException e2) { ! LogService.instance().log(LogService.ERROR, "Database connection error " + e2); ! throw new RAPDBException("Database connection error", e2); ! } } --- 61,68 ---- * This method makes a database connection to the specified database. * @param dbName the name of the database to connect to. ! * @see edu.fullcoll.uportal.channels.rap.forum.database.DatabaseNames */ ! protected Connection getDBConnection(String dbName) throws RAPDBException { ! return RDBMServices.getConnection(dbName); } *************** *** 108,112 **** * @throws RAPDBException - if a database error occurs */ ! protected void closeConnection() throws RAPDBException { try { --- 71,75 ---- * @throws RAPDBException - if a database error occurs */ ! protected void closeConnection(Connection dbConnection) throws RAPDBException { try { *************** *** 166,171 **** --- 129,136 ---- private void getChannelDSConfig() { if(RAPDBConfig.getInstance().isMultiDS()) { + //System.out.println("Default db: "+ DatabaseNames.PORTAL_CHANNELS); defaultDSName = DatabaseNames.PORTAL_CHANNELS; } else { + //System.out.println("Default db: "+DatabaseNames.PORTAL); defaultDSName = DatabaseNames.PORTAL; } |