Home > front end >  Druid query can query the database, found out wrong, I don't feel like gibberish, but don'
Druid query can query the database, found out wrong, I don't feel like gibberish, but don'

Time:10-09

The servlet code:
Protected void doGet (it request, HttpServletResponse response) throws ServletException, IOException {
//TODO Auto - generated method stub
//response. GetWriter (). Append (" Served at: "), append (request) getContextPath ());
UserDaoImpl dao=new UserDaoImpl ();
List User=dao. The.findall ();
System.out.println(user);
}

The dao code:
Public class UserDaoImpl {

Private=new JdbcTemplate JdbcTemplate JDBC (DruidUtil getDataSource ());
Public List The.findall () {
//TODO Auto - generated method stub

String SQL="select * from user1";
List The users=JDBC query (SQL, new BeanPropertyRowMapper (Login. Class));
return users;
}


}

Domain code:
Public class Login {

private String name;
private String password;
Public String getName () {
return name;
}
Public void elegantly-named setName (String name) {
this.name=name;
}
Public String getPassword () {
Return the password;
}
Public void setPassword (String password) {
this.password=password;
}

}




Results query out is this:
[jdbctest. Login @ 1 b84aa37 jdbctest. Login @ 560 f9a1b jdbctest. Login @ 79 e7f97e]
I don't know is what thing,

Query out the right should be like this:
[Login [name=zhangsan, password=123], the Login [name=zhang SAN, password=123], the Login [name=lisi, password=123]]


CodePudding user response:

Please bosses to help have a look at it, really desperate, I don't know why

CodePudding user response:

In fact you have found out, just you output is the object's memory address
Want to be the format you want to rewrite the Login toString method

CodePudding user response:

refer to the second floor jack5246 response:
actually you already found out, you just output is the object's memory address
Want to be the format you want to rewrite the Login toString method

Thank you for your reply, I already rewrite the toString method, or not, still the same result

CodePudding user response:

reference 3 floor ratty reply:
Quote: refer to the second floor jack5246 response:
actually you already found out, you just output is the object's memory address
Want to be the format you want to rewrite the Login toString method

Thank you for your reply, I already rewrite the toString method, or not, still the same result


Stick your toString code come out and have a look

CodePudding user response:

reference 4 floor jack5246 response:
Quote: reference 3 floor ratty reply:

Quote: refer to the second floor jack5246 response:
actually you already found out, you just output is the object's memory address
Want to be the format you want to rewrite the Login toString method

Thank you for your reply, I already rewrite the toString method, or not, still the same result


Stick your toString code out

This is my add toString code:
Public class Login {

private String name;
private String password;
Public String getName () {
return name;
}
Public void elegantly-named setName (String name) {
this.name=name;
}
Public String getPassword () {
Return the password;
}
Public void setPassword (String password) {
this.password=password;
}
@ Override
Public String toString () {
Return "Login [name=" + name + ", "=" + "+"] ".
}


}

CodePudding user response:

refer to fifth floor ratty reply:
Quote: refer to 4th floor jack5246 response:

Quote: refer to 3rd floor ratty reply:

Quote: refer to the second floor jack5246 response:
actually you already found out, you just output is the object's memory address
Want to be the format you want to rewrite the Login toString method

Thank you for your reply, I already rewrite the toString method, or not, still the same result


Stick your toString code out

This is my add toString code:
Public class Login {

private String name;
private String password;
Public String getName () {
return name;
}
Public void elegantly-named setName (String name) {
this.name=name;
}
Public String getPassword () {
Return the password;
}
Public void setPassword (String password) {
this.password=password;
}
@ Override
Public String toString () {
Return "Login [name=" + name + ", "=" + "+"] ".
}


}


So should have no problem, see if you have caching, such as check again

CodePudding user response:

refer to 6th floor jack5246 response:
Quote: refer to fifth floor ratty reply:

Quote: refer to 4th floor jack5246 response:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related