1 package org.mvnforum.phpbb2mvnforum.db.jdbc; 2 3 import java.sql.Connection ; 4 import java.sql.PreparedStatement ; 5 import java.sql.ResultSet ; 6 import java.sql.SQLException ; 7 8 import net.myvietnam.mvncore.exception.DatabaseException; 9 import net.myvietnam.mvncore.exception.ObjectNotFoundException; 10 11 import org.mvnforum.phpbb2mvnforum.db.PhpbbPrivmMsgsText; 12 import org.mvnforum.phpbb2mvnforum.db.PhpbbPrivmMsgsTextDAO; 13 import org.mvnforum.util.DBUtils; 14 15 public class PhpbbPrivmMsgsTextDAOImpl implements PhpbbPrivmMsgsTextDAO{ 16 17 21 public PhpbbPrivmMsgsText getBean(int privmsgs_text_id) throws ObjectNotFoundException, DatabaseException { 22 23 Connection connection = null; 24 PreparedStatement statement = null; 25 ResultSet resultSet = null; 26 StringBuffer sql = new StringBuffer (512); 27 sql.append("SELECT privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text"); 28 sql.append(" FROM " + TABLE_NAME); 29 sql.append(" WHERE privmsgs_text_id = ?"); 30 try { 31 connection = DBUtils.getPhpbbConnection(); 32 statement = connection.prepareStatement(sql.toString()); 33 statement.setInt(1, privmsgs_text_id); 34 resultSet = statement.executeQuery(); 35 if(!resultSet.next()) { 36 throw new ObjectNotFoundException("Cannot find the row in table phpbb_privmsgs_text where primary key = (" + privmsgs_text_id + ")."); 37 } 38 39 PhpbbPrivmMsgsText bean = new PhpbbPrivmMsgsText(); 40 bean.setprivmsgs_text_id(resultSet.getInt("privmsgs_text_id")); 43 bean.setprivmsgs_bbcode_uid(resultSet.getString("privmsgs_bbcode_uid")); 44 bean.setprivmsgs_text(resultSet.getString("privmsgs_text")); 45 return bean; 46 } catch(SQLException sqle) { 47 throw new DatabaseException("Error executing SQL in phpbb_privmsgs_textDAOImplJDBC.getBean(pk)."); 48 } finally { 49 DBUtils.closeResultSet(resultSet); 50 DBUtils.closeStatement(statement); 51 DBUtils.closeConnection(connection); 52 } 53 } 54 55 56 57 } 58 | Popular Tags |