a Collection of beans to store sql data 2007-01-10 - By Michael Ni
Back I was wondering if anyone could help with this. As recommended by forum members, I am using a Collection of beans to store the data from sql query.
My problem is i get
PersonNew.java:48: missing return statement } ^
I found some information on the subject on
http://forum.java.sun.com/thread.jspa?threadID=656115&messageID=3856479
however it doesn't provide a solution
-- ----Here is my code -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ -- --
package beanpersonal; import beandatabase.DBConnection;
import java.sql.Connection ; import java.sql.SQLException ; import javax.naming.InitialContext ; import javax.naming.NamingException ; import javax.sql.DataSource ; import java.util.Collection ; import java.sql.PreparedStatement ; import java.sql.ResultSet ; import java.util.ArrayList ;
public class PersonNew {
public PersonNew() { }
public Collection getPersondata( String alias, String password ) {
Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; Collection retValue = new ArrayList(); String query = "SELECT * FROM person WHERE alias = ?, password = ?"; try { conn = DBConnection.getDBConnection(); stmt = conn.prepareStatement( query ); stmt.setString( 1, alias ); stmt.setString( 2, password ); rs = stmt.executeQuery(); while (rs.next()) { PersonalInfo beanrow = new PersonalInfo(); beanrow.setAlias(rs.getString("alias")); beanrow.setPassword(rs.getString("password")); retValue.add(beanrow);
} return retValue; } catch( SQLException sqle ) { sqle.printStackTrace(); } finally { try {if (rs != null) rs.close();} catch (SQLException e) {} try {if (stmt != null) stmt.close();} catch (SQLException e) {} try {if (conn != null) conn.close();} catch (SQLException e) {} } }
}
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __ Find sales, coupons, and free shipping, all in one place! ?MSN Shopping Sales & Deals http://shopping.msn.com/content/shp/?ctid=198,ptnrid=176,ptnrdata=200639
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ To start a new topic, e-mail: users@(protected) To unsubscribe, e-mail: users-unsubscribe@(protected) For additional commands, e-mail: users-help@(protected)
|
|