Win a copy of Rust Web Development this week in the Other Languages forum!
    Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I am moving this to the appropriate forum. This is not an SCJD question.
Mark
 
Mark Spritzler
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic