use of net.jforum.exceptions.DatabaseException in project jforum2 by rafaelsteil.
the class GenericBookmarkDAO method getUsers.
protected List getUsers(int userId) {
List l = new ArrayList();
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("BookmarkModel.selectUserBookmarks"));
p.setInt(1, userId);
rs = p.executeQuery();
while (rs.next()) {
Bookmark b = this.getBookmark(rs);
if (b.getTitle() == null || "".equals(b.getTitle())) {
b.setTitle(rs.getString("username"));
}
l.add(b);
}
return l;
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(rs, p);
}
}
use of net.jforum.exceptions.DatabaseException in project jforum2 by rafaelsteil.
the class GenericBookmarkDAO method getTopics.
protected List getTopics(int userId) {
PreparedStatement p = null;
ResultSet rs = null;
try {
List l = new ArrayList();
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("BookmarkModel.selectTopicBookmarks"));
p.setInt(1, userId);
rs = p.executeQuery();
while (rs.next()) {
Bookmark b = this.getBookmark(rs);
if (b.getTitle() == null || "".equals(b.getTitle())) {
b.setTitle(rs.getString("topic_title"));
}
l.add(b);
}
return l;
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(rs, p);
}
}
use of net.jforum.exceptions.DatabaseException in project jforum2 by rafaelsteil.
the class GenericBookmarkDAO method add.
/**
* @see net.jforum.dao.BookmarkDAO#add(net.jforum.entities.Bookmark)
*/
public void add(Bookmark b) {
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("BookmarkModel.add"));
p.setInt(1, b.getUserId());
p.setInt(2, b.getRelationId());
p.setInt(3, b.getRelationType());
p.setInt(4, b.isPublicVisible() ? 1 : 0);
p.setString(5, b.getTitle());
p.setString(6, b.getDescription());
p.executeUpdate();
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(p);
}
}
use of net.jforum.exceptions.DatabaseException in project jforum2 by rafaelsteil.
the class GenericCategoryDAO method selectAll.
/**
* @see net.jforum.dao.CategoryDAO#selectAll()
*/
public List selectAll() {
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("CategoryModel.selectAll"));
List l = new ArrayList();
rs = p.executeQuery();
while (rs.next()) {
l.add(this.getCategory(rs));
}
return l;
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(rs, p);
}
}
use of net.jforum.exceptions.DatabaseException in project jforum2 by rafaelsteil.
the class GenericCategoryDAO method selectById.
/**
* @see net.jforum.dao.CategoryDAO#selectById(int)
*/
public Category selectById(int categoryId) {
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("CategoryModel.selectById"));
p.setInt(1, categoryId);
rs = p.executeQuery();
Category c = new Category();
if (rs.next()) {
c = this.getCategory(rs);
}
return c;
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(rs, p);
}
}
Aggregations