Bookmark Topic Watch Topic
  • New Topic

why i get the incorrect data from mySQL????

 
leo tien
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Report post to moderator
I want get data from mySQL.
mySQL's table as following:
+---------+--------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------------------+------+-----+---------+-------+
| article | int(4) unsigned zerofill | | PRI | 0000 | |
| dealer | char(20) | | PRI | | |
| price | double(16,2) | | | 0.00 | |
+---------+--------------------------+------+-----+---------+-------+
my table is :
+---------+--------+-------+
| article | dealer | price |
+---------+--------+-------+
| 0001 | A | 3.45 |
| 0001 | B | 3.99 |
| 0002 | A | 10.99 |
| 0003 | B | 1.45 |
| 0003 | C | 1.69 |
| 0003 | D | 1.25 |
| 0004 | D | 19.95 |
+---------+--------+-------+
then I get the data from it ,
......
ResultSet result;
ResultSetMetaData rs;
......
while(result.next()) {
System.out.println(result.getString(
rs.getColumnName(1)));
/*this sentence can not run.
System.out.println(result.getInt(
rs.getColumnName(1)));
*/
System.out.println(result.getString(
rs.getColumnName(2)));
System.out.println(result.getDouble(
rs.getColumnName(3)));
}
......
it display:
......
Article : pppq
Dealer :
price : 3.45
......
as you see, the problem take place: the article's data isn't "pppq", why occur this error? How can I resolve it??please help ,,,thanks....
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Report post to moderator
This sounds like a fun new developer assignment. I suggest you post it also to "Architect Certificatiion", "Weblogic", and "UML and Refactoring" forums, just to see how much JavaRanch can tolerate
Eugene.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Report post to moderator
I am moving this to the appropriate forum. This is not an SCJD question.
Mark
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Report post to moderator
Actually I am just going to close this thread because it is a duplicate post that is also posting in the JDBC forum, which is a mroe appropriate forum.
Please try to refrain from duplicate cross posts.
Mark
 
    Bookmark Topic Watch Topic
  • New Topic