001: /*
002: * $Header: /cvsroot/mvnforum/mvnforum/contrib/phpbb2mvnforum/src/org/mvnforum/phpbb2mvnforum/db/jdbc/PhpbbPrivmMsgsTextDAOImpl.java,v 1.4 2007/12/18 04:58:44 minhnn Exp $
003: * $Author: minhnn $
004: * $Revision: 1.4 $
005: * $Date: 2007/12/18 04:58:44 $
006: *
007: * ====================================================================
008: *
009: * Copyright (C) 2002-2007 by MyVietnam.net
010: *
011: * All copyright notices regarding mvnForum MUST remain
012: * intact in the scripts and in the outputted HTML.
013: * The "powered by" text/logo with a link back to
014: * http://www.mvnForum.com and http://www.MyVietnam.net in
015: * the footer of the pages MUST remain visible when the pages
016: * are viewed on the internet or intranet.
017: *
018: * This program is free software; you can redistribute it and/or modify
019: * it under the terms of the GNU General Public License as published by
020: * the Free Software Foundation; either version 2 of the License, or
021: * any later version.
022: *
023: * This program is distributed in the hope that it will be useful,
024: * but WITHOUT ANY WARRANTY; without even the implied warranty of
025: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
026: * GNU General Public License for more details.
027: *
028: * You should have received a copy of the GNU General Public License
029: * along with this program; if not, write to the Free Software
030: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
031: *
032: * Support can be obtained from support forums at:
033: * http://www.mvnForum.com/mvnforum/index
034: *
035: * Correspondence and Marketing Questions can be sent to:
036: * info at MyVietnam net
037: *
038: * @author:
039: */
040: package org.mvnforum.phpbb2mvnforum.db.jdbc;
041:
042: import java.sql.Connection;
043: import java.sql.PreparedStatement;
044: import java.sql.ResultSet;
045: import java.sql.SQLException;
046:
047: import net.myvietnam.mvncore.exception.DatabaseException;
048: import net.myvietnam.mvncore.exception.ObjectNotFoundException;
049:
050: import org.mvnforum.phpbb2mvnforum.db.PhpbbPrivmMsgsText;
051: import org.mvnforum.phpbb2mvnforum.db.PhpbbPrivmMsgsTextDAO;
052: import org.mvnforum.util.DBUtils;
053:
054: public class PhpbbPrivmMsgsTextDAOImpl implements PhpbbPrivmMsgsTextDAO {
055:
056: /*
057: * Included columns: privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text
058: * Excluded columns:
059: */
060: public PhpbbPrivmMsgsText getBean(int privmsgs_text_id)
061: throws ObjectNotFoundException, DatabaseException {
062:
063: Connection connection = null;
064: PreparedStatement statement = null;
065: ResultSet resultSet = null;
066: StringBuffer sql = new StringBuffer(512);
067: sql
068: .append("SELECT privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text");
069: sql.append(" FROM " + TABLE_NAME);
070: sql.append(" WHERE privmsgs_text_id = ?");
071: try {
072: connection = DBUtils.getPhpbbConnection();
073: statement = connection.prepareStatement(sql.toString());
074: statement.setInt(1, privmsgs_text_id);
075: resultSet = statement.executeQuery();
076: if (!resultSet.next()) {
077: throw new ObjectNotFoundException(
078: "Cannot find the row in table phpbb_privmsgs_text where primary key = ("
079: + privmsgs_text_id + ").");
080: }
081:
082: PhpbbPrivmMsgsText bean = new PhpbbPrivmMsgsText();
083: // @todo: uncomment the following line(s) as needed
084: //bean.setprivmsgs_text_id(privmsgs_text_id);
085: bean.setprivmsgs_text_id(resultSet
086: .getInt("privmsgs_text_id"));
087: bean.setprivmsgs_bbcode_uid(resultSet
088: .getString("privmsgs_bbcode_uid"));
089: bean.setprivmsgs_text(resultSet.getString("privmsgs_text"));
090: return bean;
091: } catch (SQLException sqle) {
092: throw new DatabaseException(
093: "Error executing SQL in phpbb_privmsgs_textDAOImplJDBC.getBean(pk).");
094: } finally {
095: DBUtils.closeResultSet(resultSet);
096: DBUtils.closeStatement(statement);
097: DBUtils.closeConnection(connection);
098: }
099: }
100:
101: }
|