• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting null values from DB

 
prasad naga
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

I am having a requirement to get the roles from the Role table which consists of roleid and rolename and should be display in the jsp.
Here my BO consists of

String sqlQuery = "Select * from Role order by Name";
RoleDAO roleDAO = new RoleDAO();
ArrayList roleList = roleDAO.listRole(sqlQuery);
System.out.println("rolelist size :"+roleList.size());
RoleTO roleto =new RoleTO();
String n = roleto.getRoleName();
System.out.println(n);

and in DAO

public ArrayList listRole(String sqlQuery) {
RoleTO roleTO = null;
ArrayList roleList = new ArrayList();
try{
connection = ConnectionClass.getConnection();
stmt = connection.createStatement();
result = stmt.executeQuery(sqlQuery);
while(result.next()){
roleTO = new RoleTO();
roleTO.setRoleName(result.getString("Name"));
roleTO.setRoleid(result.getInt("Role_id"));
roleList.add(roleList);
}
return roleList;
}

while i am executing it shows null values in Name and 0 for roleid

can any body give a pushup for me, so that i can be able to achive this
 
Abhishek Asthana
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am not sure about your problem but are you sure you are right when you write this :



I am asking this because I think you should be doing this:



You should add roleTO object to your arraylist. Isn't it?

Abhishek
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to JDBC.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic