[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-serv17651 Modified Files: DatabaseNames.java RAPDB.java RAPDBConfig.java RAPDBException.java RAPDBService.java Log Message: no message Index: RAPDBException.java =================================================================== RCS file: /cvsroot/rapforums/src/source/edu/fullcoll/uportal/channels/rap/forum/database/RAPDBException.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RAPDBException.java 26 Jan 2004 18:55:50 -0000 1.3 --- RAPDBException.java 4 Feb 2005 00:56:53 -0000 1.4 *************** *** 25,33 **** 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.3 $Revision %G% */ public class RAPDBException extends RAPException { --- 25,32 ---- 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.9.0 $Revision %G% */ public class RAPDBException extends RAPException { Index: RAPDB.java =================================================================== RCS file: /cvsroot/rapforums/src/source/edu/fullcoll/uportal/channels/rap/forum/database/RAPDB.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RAPDB.java 26 Jan 2004 18:55:50 -0000 1.3 --- RAPDB.java 4 Feb 2005 00:56:53 -0000 1.4 *************** *** 55,59 **** * * @author Brad Rippe (br...@fu...) ! * @version 0.8.3 $Revision %G% */ public class RAPDB extends RAPDBService { --- 55,59 ---- * * @author Brad Rippe (br...@fu...) ! * @version 0.9.0 $Revision %G% */ public class RAPDB extends RAPDBService { *************** *** 68,71 **** --- 68,73 ---- = "select forumid, name, description, creationdate, modifieddate, " + "categoryid from rapforum where forumid=?"; + private final static String SELECT_FORUM_NAME + = "select name from rapforum where forumid=?"; private final static String SELECT_FORUM4 = "select forumid, name, description, creationdate, modifieddate, " *************** *** 74,81 **** --- 76,87 ---- = "select forumid, name, description, creationDate " +"from rapforum where categoryid = ?"; + private final static String SELECT_ALL_FORUM_IDS + = "select forumid from rapforum order by forumid"; private final static String INSERT_FORUM = "insert into rapforum (forumid, name, description, categoryid, creationdate, modifieddate) VALUES (?, ?, ?, ?, ?, ?)"; private final static String DELETE_FORUM = "delete from rapforum where categoryid = ? AND forumid = ?"; + private final static String RENAME_FORUM + = "update rapforum set name = ? where forumid = ?"; // THREAD QUERIES *************** *** 134,138 **** // CATEGORY QUERIES private final static String SELECT_ALL_CATEGORIES ! = "select categoryid, name, description, creationdate, modifieddate, lft, rgt from rapcategory"; private final static String SELECT_CATEGORY = "select categoryid, name, description, creationdate, modifieddate, lft, rgt " --- 140,144 ---- // CATEGORY QUERIES private final static String SELECT_ALL_CATEGORIES ! = "select categoryid, name, description, creationdate, modifieddate, lft, rgt from rapcategory order by name"; private final static String SELECT_CATEGORY = "select categoryid, name, description, creationdate, modifieddate, lft, rgt " *************** *** 169,173 **** e.printStackTrace(); ! throw new RAPDBException("Unkown Error Occured", e); } finally { // "closing" the Connection closes its handle and --- 175,179 ---- e.printStackTrace(); ! throw new RAPDBException("Unknown Error Occured", e); } finally { // "closing" the Connection closes its handle and *************** *** 259,263 **** LogService.instance().log(LogService.ERROR, "DB ERROR: " + e); e.printStackTrace(); ! throw new RAPDBException("Unkown Error Occured", e); } finally { // "closing" the Connection closes its handle and --- 265,269 ---- LogService.instance().log(LogService.ERROR, "DB ERROR: " + e); e.printStackTrace(); ! throw new RAPDBException("Unknown Error Occured", e); } finally { // "closing" the Connection closes its handle and *************** *** 283,291 **** * Returns the forum with the specified forum id * @param the id of the forum ! * @return the forum with the specified id, otherwise null if the forum now found. * @see edu.fullcoll.uportal.channels.rap.forum.IForum */ public IForum getForum(int forumID) throws RAPDBException { IForum forum = null; PreparedStatement stmt = null; --- 289,299 ---- * Returns the forum with the specified forum id * @param the id of the forum ! * @return the forum with the specified id, otherwise null if the forum not found. * @see edu.fullcoll.uportal.channels.rap.forum.IForum */ public IForum getForum(int forumID) throws RAPDBException { + System.out.println("Getting forum "+forumID); + IForum forum = null; PreparedStatement stmt = null; *************** *** 313,317 **** LogService.instance().log(LogService.ERROR, "DB ERROR: " + sqle.getMessage()); sqle.printStackTrace(); - throw new RAPDBException("Nested SQL Error", sqle); } catch (Exception e) { --- 321,324 ---- *************** *** 319,323 **** e.printStackTrace(); System.out.println(e.getMessage()); ! throw new RAPDBException("Unkown Error Occured", e); } finally { // "closing" the Connection closes its handle and --- 326,330 ---- e.printStackTrace(); System.out.println(e.getMessage()); ! throw new RAPDBException("Unknown Error Occured", e); } finally { // "closing" the Connection closes its handle and *************** *** 331,334 **** --- 338,382 ---- /** + * Returns the forum name with the specified forum id + * @param the id of the forum + * @return the forum name with the specified id, otherwise an empty string if the forum not found. + */ + public String getForumName(int forumID) throws RAPDBException { + IForum forum = null; + PreparedStatement stmt = null; + ResultSet rs = null; + Connection dbConnection = null; + + try { + dbConnection = getDBConnection(); + //todo change to callable + stmt = dbConnection.prepareStatement(SELECT_FORUM_NAME, + ResultSet.TYPE_SCROLL_INSENSITIVE, + ResultSet.CONCUR_READ_ONLY); + stmt.setInt(1, forumID); + rs = stmt.executeQuery(); + if (rs.next()) { + return rs.getString("name"); + } + } catch (SQLException sqle) { + LogService.instance().log(LogService.ERROR, "DB ERROR: " + sqle.getMessage()); + sqle.printStackTrace(); + throw new RAPDBException("Nested SQL Error", sqle); + } catch (Exception e) { + LogService.instance().log(LogService.ERROR, "DB ERROR: " + e.getMessage()); + e.printStackTrace(); + System.out.println(e.getMessage()); + throw new RAPDBException("Unknown Error Occured", e); + } finally { + // "closing" the Connection closes its handle and + // returns the actual connection to its pool: + closeStatement(stmt); + closeResultSet(rs); + closeConnection(dbConnection); + } + return ""; + } + + /** * Returns a collection of forums by the specified category id. * @param catID the category id for the associated forums *************** *** 361,365 **** LogService.instance().log(LogService.ERROR, "DB ERROR: " + e); e.printStackTrace(); ! throw new RAPDBException("Unkown Error Occured", e); } finally { closeStatement(stmt); --- 409,449 ---- LogService.instance().log(LogService.ERROR, "DB ERROR: " + e); e.printStackTrace(); ! throw new RAPDBException("Unknown Error Occured", e); ! } finally { ! closeStatement(stmt); ! closeResultSet(rs); ! closeConnection(dbConnection); ! } ! } ! ! /** ! * Returns a collection of forums by the specified category id. ! * @param catID the category id for the associated forums ! * @return a collection of forums associated with a category ! */ ! public Collection getForumIDs() throws RAPDBException { ! PreparedStatement stmt = null; ! ResultSet rs = null; ! Connection dbConnection = null; ! try { ! dbConnection = getDBConnection(); ! stmt = dbConnection.prepareStatement(SELECT_ALL_FORUM_IDS, ! ResultSet.TYPE_SCROLL_INSENSITIVE, ! ResultSet.CONCUR_READ_ONLY); ! rs = stmt.executeQuery(); ! ArrayList forumids = new ArrayList(); ! while(rs.next()) { ! int forumID = rs.getInt("forumid"); ! if(forumID != 0) { ! Integer tempInt = new Integer(forumID); ! forumids.add(tempInt.toString()); ! } ! } ! return forumids; ! ! } catch(Exception e) { ! LogService.instance().log(LogService.ERROR, "DB ERROR: " + e); ! e.printStackTrace(); ! throw new RAPDBException("Unknown Error Occured", e); } finally { closeStatement(stmt); *************** *** 410,414 **** e.printStackTrace(); System.out.println(e.getMessage()); ! throw new RAPDBException("Unkown Error Occured", e); } finally { // "closing" the Connection closes its handle and --- 494,535 ---- e.printStackTrace(); System.out.println(e.getMessage()); ! throw new RAPDBException("Unknown Error Occured", e); ! } finally { ! // "closing" the Connection closes its handle and ! // returns the actual connection to its pool: ! closeStatement(stmt); ! closeConnection(dbConnection); ! } ! } ! ! /** ! * Renames a forum's name. ! * @param newName the new title of the forum. ! * @param forumID the id of the forum to be removed. ! * @return the row count for the number of forums renamed. ! */ ! public int renameForum(String newName, int forumID) throws RAPDBException { ! PreparedStatement stmt = null; ! Connection dbConnection = null; ! try { ! //rename the forum ! dbConnection = getDBConnection(); ! stmt = dbConnection.prepareStatement(RENAME_FORUM, ! ResultSet.TYPE_SCROLL_INSENSITIVE, ! ResultSet.CONCUR_READ_ONLY); ! stmt.setString(1, newName); ! stmt.setInt(2, forumID); ! ! return stmt.executeUpdate(); ! ! } catch (SQLException sqle) { ! LogService.instance().log(LogService.ERROR, "DB ERROR: " + sqle.getMessage()); ! sqle.printStackTrace(); ! throw new RAPDBException("Nested SQL Error", sqle); ! } catch (Exception e) { ! LogService.instance().log(LogService.ERROR, "DB ERROR: " + e.getMessage()); ! e.printStackTrace(); ! System.out.println(e.getMessage()); ! throw new RAPDBException("Unknown Error Occured", e); } finally { // "closing" the Connection closes its handle and *************** *** 443,447 **** //Set creation and modified dates GregorianCalendar cal = new GregorianCalendar(); ! Date creationModDate = new java.sql.Date(cal.getTimeInMillis()); stmt.setInt(1, threadID); --- 564,568 ---- //Set creation and modified dates GregorianCalendar cal = new GregorianCalendar(); ! java.sql.Date creationModDate = new java.sql.Date(cal.getTimeInMillis()); stmt.setInt(1, threadID); *************** *** 467,471 **** e.printStackTrace(); ! throw new RAPDBException("Unkown Error Occured", e); } finally { closeStatement(stmt); --- 588,592 ---- e.printStackTrace(); ! throw new RAPDBException("Unknown Error Occured", e); } finally { closeStatement(stmt); *************** *** 520,524 **** e.printStackTrace(); ! throw new RAPDBException("Unkown Error Occured", e); } finally { closeStatement(stmt); --- 641,645 ---- e.printStackTrace(); ! throw new RAPDBException("Unknown Error Occured", e); } finally { closeStatement(stmt); *************** *** 566,570 **** e.printStackTrace(); ! throw new RAPDBException("Unkown Error Occured", e); } finally { closeStatement(stmt); --- 687,691 ---- e.printStackTrace(); ! throw new RAPDBException("Unknown Error Occured", e); } finally { closeStatement(stmt); *************** *** 604,608 **** e.printStackTrace(); ! throw new RAPDBException("Unkown Error Occured", e); } finally { // "closing" the Connection closes its handle and --- 725,729 ---- e.printStackTrace(); ! throw new RAPDBException("Unknown Error Occured", e); } finally { // "closing" the Connection closes its handle and *************** *** 655,659 **** e.printStackTrace(); System.out.println(e.getMessage()); ! throw new RAPDBException("Unkown Error Occured", e); } finally { // "closing" the Connection closes its handle and --- 776,780 ---- e.printStackTrace(); System.out.println(e.getMessage()); ! throw new RAPDBException("Unknown Error Occured", e); } finally { // "closing" the Connection closes its handle and *************** *** 725,729 **** e.printStackTrace(); ! throw new RAPDBException("Unkown Error Occured", e); } finally { closeStatement(stmt); --- 846,850 ---- e.printStackTrace(); ! throw new RAPDBException("Unknown Error Occured", e); } finally { closeStatement(stmt); *************** *** 786,790 **** e.printStackTrace(); ! throw new RAPDBException("Unkown Error Occured", e); } finally { closeStatement(stmt); --- 907,911 ---- e.printStackTrace(); ! throw new RAPDBException("Unknown Error Occured", e); } finally { closeStatement(stmt); *************** *** 837,841 **** e.printStackTrace(); ! throw new RAPDBException("Unkown Error Occured", e); } finally { closeStatement(stmt); --- 958,962 ---- e.printStackTrace(); ! throw new RAPDBException("Unknown Error Occured", e); } finally { closeStatement(stmt); *************** *** 886,890 **** e.printStackTrace(); ! throw new RAPDBException("Unkown Error Occured", e); } finally { closeStatement(stmt); --- 1007,1011 ---- e.printStackTrace(); ! throw new RAPDBException("Unknown Error Occured", e); } finally { closeStatement(stmt); *************** *** 940,944 **** e.printStackTrace(); ! throw new RAPDBException("Unkown Error Occured", e); } finally { closeStatement(stmt); --- 1061,1065 ---- e.printStackTrace(); ! throw new RAPDBException("Unknown Error Occured", e); } finally { closeStatement(stmt); *************** *** 991,995 **** e.printStackTrace(); ! throw new RAPDBException("Unkown Error Occured", e); } finally { closeStatement(stmt); --- 1112,1116 ---- e.printStackTrace(); ! throw new RAPDBException("Unknown Error Occured", e); } finally { closeStatement(stmt); *************** *** 1028,1032 **** e.printStackTrace(); System.out.println(e.getMessage()); ! throw new RAPDBException("Unkown Error Occured", e); } finally { // "closing" the Connection closes its handle and --- 1149,1153 ---- e.printStackTrace(); System.out.println(e.getMessage()); ! throw new RAPDBException("Unknown Error Occured", e); } finally { // "closing" the Connection closes its handle and *************** *** 1089,1093 **** LogService.instance().log(LogService.ERROR, "DB ERROR: " + e); e.printStackTrace(); ! throw new RAPDBException("Unkown Error Occured", e); } finally { // "closing" the Connection closes its handle and --- 1210,1214 ---- LogService.instance().log(LogService.ERROR, "DB ERROR: " + e); e.printStackTrace(); ! throw new RAPDBException("Unknown Error Occured", e); } finally { // "closing" the Connection closes its handle and *************** *** 1142,1146 **** e.printStackTrace(); System.out.println(e.getMessage()); ! throw new RAPDBException("Unkown Error Occured", e); } finally { // "closing" the Connection closes its handle and --- 1263,1267 ---- e.printStackTrace(); System.out.println(e.getMessage()); ! throw new RAPDBException("Unknown Error Occured", e); } finally { // "closing" the Connection closes its handle and *************** *** 1185,1189 **** e.printStackTrace(); System.out.println(e.getMessage()); ! throw new RAPDBException("Unkown Error Occured", e); } finally { // "closing" the Connection closes its handle and --- 1306,1310 ---- e.printStackTrace(); System.out.println(e.getMessage()); ! throw new RAPDBException("Unknown Error Occured", e); } finally { // "closing" the Connection closes its handle and *************** *** 1233,1237 **** e.printStackTrace(); System.out.println(e.getMessage()); ! throw new RAPDBException("Unkown Error Occured", e); } finally { // "closing" the Connection closes its handle and --- 1354,1358 ---- e.printStackTrace(); System.out.println(e.getMessage()); ! throw new RAPDBException("Unknown Error Occured", e); } finally { // "closing" the Connection closes its handle and *************** *** 1267,1272 **** String name = rs.getString("name"); String desc = rs.getString("description"); Date creationDate = rs.getDate("creationdate"); ! Date modifiedDate = rs.getDate("modifieddate"); int lft = rs.getInt("lft"); int rgt = rs.getInt("rgt"); --- 1388,1395 ---- String name = rs.getString("name"); String desc = rs.getString("description"); + // SQL the date is stored as date + // ORACLE the date is stored as TimeStamp Date creationDate = rs.getDate("creationdate"); ! Date modifiedDate = rs.getDate("modifieddate"); int lft = rs.getInt("lft"); int rgt = rs.getInt("rgt"); *************** *** 1281,1285 **** e.printStackTrace(); ! throw new RAPDBException("Unkown Error Occured", e); } finally { closeStatement(stmt); --- 1404,1408 ---- e.printStackTrace(); ! throw new RAPDBException("Unknown Error Occured", e); } finally { closeStatement(stmt); *************** *** 1326,1330 **** e.printStackTrace(); ! throw new RAPDBException("Unkown Error Occured", e); } finally { closeStatement(stmt); --- 1449,1453 ---- e.printStackTrace(); ! throw new RAPDBException("Unknown Error Occured", e); } finally { closeStatement(stmt); *************** *** 1384,1388 **** e.printStackTrace(); ! throw new RAPDBException("Unkown Error Occured", e); } finally { closeStatement(stmt); --- 1507,1511 ---- e.printStackTrace(); ! throw new RAPDBException("Unknown Error Occured", e); } finally { closeStatement(stmt); *************** *** 1440,1444 **** e.printStackTrace(); System.out.println(e.getMessage()); ! throw new RAPDBException("Unkown Error Occured", e); } finally { // "closing" the Connection closes its handle and --- 1563,1567 ---- e.printStackTrace(); System.out.println(e.getMessage()); ! throw new RAPDBException("Unknown Error Occured", e); } finally { // "closing" the Connection closes its handle and Index: RAPDBConfig.java =================================================================== RCS file: /cvsroot/rapforums/src/source/edu/fullcoll/uportal/channels/rap/forum/database/RAPDBConfig.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RAPDBConfig.java 26 Jan 2004 18:55:38 -0000 1.1 --- RAPDBConfig.java 4 Feb 2005 00:56:53 -0000 1.2 *************** *** 28,32 **** * * @author br...@fu... (Brad Rippe) ! * @version 0.8.3 $Revision %G% */ public class RAPDBConfig { --- 28,32 ---- * * @author br...@fu... (Brad Rippe) ! * @version 0.9.0 $Revision %G% */ public class RAPDBConfig { Index: DatabaseNames.java =================================================================== RCS file: /cvsroot/rapforums/src/source/edu/fullcoll/uportal/channels/rap/forum/database/DatabaseNames.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DatabaseNames.java 26 Jan 2004 18:55:50 -0000 1.3 --- DatabaseNames.java 4 Feb 2005 00:56:53 -0000 1.4 *************** *** 28,32 **** * * @author Brad Rippe (br...@fu...) ! * @version 0.8.3 $Revision %G% */ public interface DatabaseNames { --- 28,32 ---- * * @author Brad Rippe (br...@fu...) ! * @version 0.9.0 $Revision %G% */ public interface DatabaseNames { Index: RAPDBService.java =================================================================== RCS file: /cvsroot/rapforums/src/source/edu/fullcoll/uportal/channels/rap/forum/database/RAPDBService.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RAPDBService.java 26 Jan 2004 18:55:50 -0000 1.3 --- RAPDBService.java 4 Feb 2005 00:56:53 -0000 1.4 *************** *** 36,40 **** * * @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 --- 36,40 ---- * * @author Brad Rippe (br...@fu...) ! * @version 0.9.0 $Revision %G% * @see org.jasig.portal.RDBMServices * @see edu.fullcoll.uportal.channels.rap.forum.database.RAPDBConfig |