return both user name and password

hi

I have small code

public String validateUser(String userId, String password)

throws SQLException, ClassNotFoundException{

String returnString =null;

Connection con=null;

//get free connection from pool

con =connectionPool.getConnection();

Statementstmt = con.createStatement(

ResultSet.TYPE_SCROLL_SENSITIVE,

ResultSet.CONCUR_READ_ONLY);

String sql ="select password from users where Name='"+userId+"' and password='"+password+"'";

ResultSet rs = stmt.executeQuery(sql);

if (rs.next())

{

returnString = rs.getString("password");

}

connectionPool.returnConnection(con);

stmt.close();

con.close();

return returnString;

}

if I want to return both User Id and Password, How should I modify the code.

Thank you!

[1309 byte] By [TMarya] at [2007-11-26 15:41:00]
# 1

Hi TMary,

I think you should make wrapper class that contains userID and Password because as we are programmer knowledge, we cant return 2 objects! So maybe you should make wrapper class like

class User

{

public userName;

public password;

}

you can also make private and make public get and set method

I hope that can help you!

From wizz

-wizz-a at 2007-7-8 21:59:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...