WPI GDC CMS 0.0.1

org.wpi.gdc.cms.db.jdbc
Class MySQLDBEngine

java.lang.Object
  |
  +--org.wpi.gdc.cms.db.DBEngine
        |
        +--org.wpi.gdc.cms.db.jdbc.MySQLDBEngine

public class MySQLDBEngine
extends DBEngine

DBEngine for use with a MySQL database backend.

Version:
1.14
Author:
dmpotter

Fields inherited from class org.wpi.gdc.cms.db.DBEngine
INCLUDE_AFTER_TODAY, INCLUDE_BEFORE_TODAY, ORDER_ASCENDING, ORDER_DESCENDING, session
 
Constructor Summary
MySQLDBEngine()
           
 
Method Summary
 void connect(java.lang.String dbURL, java.util.Properties properties)
          Connects to the database using the given db URL from the configuration options.
 boolean isConnected()
          Determines if the database is connected (ie, a call to connect succeeded).
 Event loadEvent(int id)
          Events are stored in a database via a numeric ID, this method should load the actual data based on the ID.
 Event loadEvent(java.lang.String name)
          Each events to be accessed through the website must have a unique name identifier (which will correspond with that event's URL).
 int loadEventCount()
          Counts the number of event groups available.
 DBIterator loadEvents()
          Gets an DBIterator over the event groups in the database.
 DBIterator loadEvents(int field, int order)
          Gets a DBIterator over the event groups in the database, ordered by the given order.
 DBIterator loadEvents(int field, int order, int limit)
          Gets a DBIterator over the event groups in the database, ordered by the given order, and limited to the given amount.
 DBIterator loadEventsFromDate(int range, int order, int limit)
          Gets a DBIterator over the event groups in the database, either before or after the current day (determined by range), ordered by the given order, and limited to the given amount.
 Icon[] loadIcons()
          Gets all the Icons in a database.
 DBIterator loadNewsStories()
          Gets an DBIterator over the news stories in the database.
 DBIterator loadNewsStories(int field, int order)
          Gets a DBIterator over the news stories in the database, ordered by the given order.
 DBIterator loadNewsStories(int field, int order, int limit)
          Gets a DBIterator over the news stories in the database, ordered by the given order, and limited to the given amount.
 NewsStory loadNewsStory(int id)
          News stories are stored in a database via a numeric ID, this method should load the actual data based on the ID.
 int loadNewsStoryCount()
          Counts the number of news stories available.
 Topic[] loadTopics()
          Gets all the Topics in a database.
 User loadUser(int id)
          Users are stored in a database via a numeric ID, this method should load the actual data based on the ID.
 User loadUser(java.lang.String name)
          Load a User from the DB based on the username.
 void saveNewsStory(NewsStory newsStory)
          Save a NewsStory into the database.
 
Methods inherited from class org.wpi.gdc.cms.db.DBEngine
setSession
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MySQLDBEngine

public MySQLDBEngine()
Method Detail

connect

public void connect(java.lang.String dbURL,
                    java.util.Properties properties)
             throws DatabaseException
Description copied from class: DBEngine
Connects to the database using the given db URL from the configuration options.
Overrides:
connect in class DBEngine
Following copied from class: org.wpi.gdc.cms.db.DBEngine
Throws:
DatabaseException - if there is an error accessing data from the database

isConnected

public boolean isConnected()
Description copied from class: DBEngine
Determines if the database is connected (ie, a call to connect succeeded).
Overrides:
isConnected in class DBEngine
Following copied from class: org.wpi.gdc.cms.db.DBEngine
Returns:
true if the database is connected and loadXXXX calls can succeed, false otherwise. A return of "true" does not guarentee success, calls may still throw a DatabaseException if something goes wrong. However, a return of false guarentees failure; all calls will throw a DatabaseException if this method returns false.

loadUser

public User loadUser(int id)
              throws DatabaseException
Description copied from class: DBEngine
Users are stored in a database via a numeric ID, this method should load the actual data based on the ID.
Overrides:
loadUser in class DBEngine
Following copied from class: org.wpi.gdc.cms.db.DBEngine
Parameters:
id - the ID for the User being loaded
Returns:
the User object loaded from the database

loadUser

public User loadUser(java.lang.String name)
              throws DatabaseException
Description copied from class: DBEngine
Load a User from the DB based on the username.
Overrides:
loadUser in class DBEngine
Following copied from class: org.wpi.gdc.cms.db.DBEngine
Parameters:
name - the username of the User being loaded
Returns:
the User object loaded from the database
Throws:
DatabaseException - if there is an error accessing data from the database

loadNewsStory

public NewsStory loadNewsStory(int id)
                        throws DatabaseException
Description copied from class: DBEngine
News stories are stored in a database via a numeric ID, this method should load the actual data based on the ID.
Overrides:
loadNewsStory in class DBEngine
Following copied from class: org.wpi.gdc.cms.db.DBEngine
Parameters:
id - the ID for the news story being loaded
Returns:
the NewsStory object loaded from the database
Throws:
DatabaseException - if there is an error accessing data from the database

loadNewsStories

public DBIterator loadNewsStories()
                           throws DatabaseException
Gets an DBIterator over the news stories in the database.

The remove() method in the DBIterator may or may not function depending on the implementation.

Overrides:
loadNewsStories in class DBEngine
Returns:
a DBIterator that retrieves one story at a time.
Throws:
DatabaseException - if there is an error accessing data from the database.

loadNewsStories

public DBIterator loadNewsStories(int field,
                                  int order)
                           throws DatabaseException
Description copied from class: DBEngine
Gets a DBIterator over the news stories in the database, ordered by the given order.
Overrides:
loadNewsStories in class DBEngine
Following copied from class: org.wpi.gdc.cms.db.DBEngine
Parameters:
field - The field to sort by, one of: NewsStory.FIELD_ID, NewsStory.FIELD_AUTHOR, NewsStory.FIELD_TOPIC, NewsStory.FIELD_POSTED, NewsStory.FIELD_HEADLINE, NewsStory.FIELD_ABSTRACT, or NewsStory.FIELD_BODY.
order - The order to sort the new stories, either DBEngine.ORDER_ASCENDING or DBEngine.ORDER_DESCENDING.
Returns:
a DBIterator that retrieves one story at a time
Throws:
java.lang.IllegalArgumentException - if field is not one of NewsStory.FIELD_ID, NewsStory.FIELD_AUTHOR, NewsStory.FIELD_TOPIC, NewsStory.FIELD_POSTED, NewsStory.FIELD_HEADLINE, NewsStory.FIELD_ABSTRACT, or NewsStory.FIELD_BODY; or if order is not either DBEngine.ORDER_ASCENDING or DBEngine.ORDER_DESCENDING.
DatabaseException - if there is an error accessing data from the database

loadNewsStories

public DBIterator loadNewsStories(int field,
                                  int order,
                                  int limit)
                           throws DatabaseException
Description copied from class: DBEngine
Gets a DBIterator over the news stories in the database, ordered by the given order, and limited to the given amount.

If the given limit is more than the number of stories in the database, only the number available will be returned and no other error will occur.

Overrides:
loadNewsStories in class DBEngine
Following copied from class: org.wpi.gdc.cms.db.DBEngine
Parameters:
field - The field to sort by, one of: NewsStory.FIELD_ID, NewsStory.FIELD_AUTHOR, NewsStory.FIELD_TOPIC, NewsStory.FIELD_POSTED, NewsStory.FIELD_HEADLINE, NewsStory.FIELD_ABSTRACT, or NewsStory.FIELD_BODY.
order - The order to sort the new stories, either DBEngine.ORDER_ASCENDING or DBEngine.ORDER_DESCENDING.
limit - The total number of stories to retrieve, or a negative number for all of them.
Returns:
a DBIterator that retrieves one story at a time.
Throws:
java.lang.IllegalArgumentException - if field is not one of NewsStory.FIELD_ID, NewsStory.FIELD_AUTHOR, NewsStory.FIELD_TOPIC, NewsStory.FIELD_POSTED, NewsStory.FIELD_HEADLINE, NewsStory.FIELD_ABSTRACT, or NewsStory.FIELD_BODY; or if order is not either DBEngine.ORDER_ASCENDING or DBEngine.ORDER_DESCENDING.
DatabaseException - if there is an error accessing data from the database

saveNewsStory

public void saveNewsStory(NewsStory newsStory)
                   throws DatabaseException
Description copied from class: DBEngine
Save a NewsStory into the database. Should the numeric ID be less than 0, the DBEngine should pick one before saving the story into the database.
Overrides:
saveNewsStory in class DBEngine
Following copied from class: org.wpi.gdc.cms.db.DBEngine
Parameters:
newsStory - the NewsStory object to save
Throws:
DatabaseException - if there is an error saving the data in the database

loadNewsStoryCount

public int loadNewsStoryCount()
                       throws DatabaseException
Description copied from class: DBEngine
Counts the number of news stories available. Returns a negative value if the number of stories could not be determined.
Overrides:
loadNewsStoryCount in class DBEngine
Following copied from class: org.wpi.gdc.cms.db.DBEngine
Returns:
the number of news stories in the database, or a negative value if the number of stories could not be determined
Throws:
DatabaseException - if there is an error accessing data from the database

loadEvent

public Event loadEvent(int id)
                throws DatabaseException
Description copied from class: DBEngine
Events are stored in a database via a numeric ID, this method should load the actual data based on the ID.
Overrides:
loadEvent in class DBEngine
Following copied from class: org.wpi.gdc.cms.db.DBEngine
Parameters:
id - the ID for the event group being loaded
Returns:
the Event object loaded from the database
Throws:
DatabaseException - if there is an error accessing data from the database

loadEvent

public Event loadEvent(java.lang.String name)
                throws DatabaseException
Description copied from class: DBEngine
Each events to be accessed through the website must have a unique name identifier (which will correspond with that event's URL). this method should load the actual data based on that name.
Overrides:
loadEvent in class DBEngine
Following copied from class: org.wpi.gdc.cms.db.DBEngine
Parameters:
name - the name for the event group being loaded
Returns:
the Event object loaded from the database
Throws:
DatabaseException - if there is an error accessing data from the database (ie, if that event does not exist)

loadEvents

public DBIterator loadEvents()
                      throws DatabaseException
Description copied from class: DBEngine
Gets an DBIterator over the event groups in the database.

The remove() method in the DBIterator may or may not function depending on the implementation.

Overrides:
loadEvents in class DBEngine
Following copied from class: org.wpi.gdc.cms.db.DBEngine
Returns:
a DBIterator that retrieves one event group at a time.
Throws:
DatabaseException - if there is an error accessing data from the database

loadEvents

public DBIterator loadEvents(int field,
                             int order)
                      throws DatabaseException
Description copied from class: DBEngine
Gets a DBIterator over the event groups in the database, ordered by the given order.
Overrides:
loadEvents in class DBEngine
Following copied from class: org.wpi.gdc.cms.db.DBEngine
Parameters:
field - The field to sort by, one of: Event.FIELD_ID, Event.FIELD_NAME, Event.FIELD_LOCATION, Event.FIELD_URL, or Event.FIELD_PAIRS.
order - The order to sort the new stories, either DBEngine.ORDER_ASCENDING or DBEngine.ORDER_DESCENDING.
Returns:
a DBIterator that retrieves one story at a time.
Throws:
java.lang.IllegalArgumentException - if field is not one of Event.FIELD_ID, Event.FIELD_NAME, Event.FIELD_LOCATION, Event.FIELD_URL, or Event.FIELD_PAIRS; or if order is not either ORDER_ASCENDING or ORDER_DESCENDING.
DatabaseException - if there is an error accessing data from the database

loadEvents

public DBIterator loadEvents(int field,
                             int order,
                             int limit)
                      throws DatabaseException
Description copied from class: DBEngine
Gets a DBIterator over the event groups in the database, ordered by the given order, and limited to the given amount.

If the given limit is more than the number of stories in the database, only the number available will be returned and no other error will occur.

Overrides:
loadEvents in class DBEngine
Following copied from class: org.wpi.gdc.cms.db.DBEngine
Parameters:
field - The field to sort by, one of: Event.FIELD_ID, Event.FIELD_NAME, Event.FIELD_LOCATION, Event.FIELD_URL, or Event.FIELD_PAIRS.
order - The order to sort the new stories, either DBEngine.ORDER_ASCENDING or DBEngine.ORDER_DESCENDING.
limit - The total number of stories to retrieve, or a negative number for all of them.
Returns:
a DBIterator that retrieves one story at a time.
Throws:
java.lang.IllegalArgumentException - if field is not one of Event.FIELD_ID, Event.FIELD_NAME, Event.FIELD_LOCATION, Event.FIELD_URL, or Event.FIELD_PAIRS; or if order is not either ORDER_ASCENDING or ORDER_DESCENDING.
DatabaseException - if there is an error accessing data from the database

loadEventsFromDate

public DBIterator loadEventsFromDate(int range,
                                     int order,
                                     int limit)
                              throws DatabaseException
Description copied from class: DBEngine
Gets a DBIterator over the event groups in the database, either before or after the current day (determined by range), ordered by the given order, and limited to the given amount.

If the given limit is more than the number of event groups in the database, only the number available will be returned and no other error will occur.

Overrides:
loadEventsFromDate in class DBEngine
Following copied from class: org.wpi.gdc.cms.db.DBEngine
Parameters:
range - Determines if database will load events before (DBEngine.INCLUDE_BEFORE_TODAY) or after (DBEngine.INCLUDE_AFTER_TODAY) the current date.
order - The order to sort the new stories, either DBEngine.ORDER_ASCENDING or DBEngine.ORDER_DESCENDING.
limit - The total number of stories to retrieve, or a negative number for all of them.
Returns:
a DBIterator that retrieves one story at a time.
Throws:
java.lang.IllegalArgumentException - if range is not either DBEngine.INCLUDE_BEFORE_TODAY or DBEngine.INCLUDE_AFTER_TODAY; or if order is not either DBEngine.ORDER_ASCENDING or DBEngine.ORDER_DESCENDING.
DatabaseException - if there is an error accessing data from the database

loadEventCount

public int loadEventCount()
                   throws DatabaseException
Description copied from class: DBEngine
Counts the number of event groups available. Returns a negative value if the number of event groups could not be determined.
Overrides:
loadEventCount in class DBEngine
Following copied from class: org.wpi.gdc.cms.db.DBEngine
Returns:
the number of event groups in the database, or a negative value if the number of stories could not be determined.
Throws:
DatabaseException - if there is an error accessing data from the database

loadIcons

public Icon[] loadIcons()
                 throws DatabaseException
Description copied from class: DBEngine
Gets all the Icons in a database.
Overrides:
loadIcons in class DBEngine
Following copied from class: org.wpi.gdc.cms.db.DBEngine
Returns:
the icons in the database
Throws:
DatabaseException - if there is an error accessing data from the database

loadTopics

public Topic[] loadTopics()
                   throws DatabaseException
Description copied from class: DBEngine
Gets all the Topics in a database.
Overrides:
loadTopics in class DBEngine
Following copied from class: org.wpi.gdc.cms.db.DBEngine
Returns:
the topics in the database
Throws:
DatabaseException - if there is an error accessing data from the database

WPI GDC CMS 0.0.1

Copyright © 2001 WPI Game Development Club. All Rights Reserved.