1 message in com.mysql.lists.javaAntwort: thanx (was: retrieving only ...| From | Sent On | Attachments |
|---|---|---|
| Sven-Volker Nowarra | 15 Mar 2001 05:32 |
| Subject: | Antwort: thanx (was: retrieving only single issues)![]() |
|---|---|
| From: | Sven-Volker Nowarra (sven...@db.com) |
| Date: | 03/15/2001 05:32:46 AM |
| List: | com.mysql.lists.java |
Thanx alot, works fine, I have checked with the manual, but couldn't find this
issue
Its in the References...:
public java.lang.String getString(int columnIndex) throws java.sql.SQLException
thanx again, Sven Volker Nowarra
GTS CTO / IT Infrastructure Project Voltaire Paris: +33 1 47 44 01 83 Eschborn: +49 69 910 62506
Datum: 15.03.2001 00:03 An: Sven-Volker Nowarra/OuB/Zentrale/DeuBa@Zentrale Kopie: ja...@lists.mysql.com
Betreff: Re: retrieving only single issues Nachrichtentext:
On Wed, 14 Mar 2001, Sven-Volker Nowarra wrote:
Hi,
I have a mysql database running, containing a database "test" (yes every mysql
installation comes with a test ...), and a table named "todo". I can do things
like "show fields from todo" or "show tables". The table has 10 fields, they are
named issue_nr, issue, who, topic, date, ...and so on.
When I do a "select * from todo" at the mysql level, I get all the fields on the
screen. However, if I do the same as a java statement, I see only 1 item,
instead of all.
I tried to go further by using a statement like "select who, topic, date", but
same behaviour...
The example is basically the one derived from the tutorial... no additional
stuff ... (here the code, without try / catch statements):
String url = "jdbc:mysql://localhost/test"; // String query = "SHOW FIELDS from todo"; String query = "SELECT ISSUE, WHO, TOPIC from todo";
Class.forName("org.gjt.mm.mysql.Driver").newInstance(); Connection Conn = DriverManager.getConnection(url);
Statement Stmt = Conn.createStatement(); ResultSet RS = Stmt.executeQuery(query); while (RS.next()) { System.out.println(RS.getString(1));
You are just printing one column here. To print the rest you need to do:
System.out.println(RS.getString(2)); System.out.println(RS.getString(3)); ...
You also need to adjust the getString to the datatype of your columns.
} RS.close();
I am using jdk1.1.3 and mm.mysql.jdbc-1.2... (though the readme files says s.th.
like 1.1 - how can I say, what I am running ?)
did I miss s.th. ?
thanx
Volker
--
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen.
Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten
haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail.
Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht
gestattet.
This e-mail may contain confidential and/or privileged information. If you are
not the intended recipient (or have received this e-mail in error) please notify
the sender immediately and destroy this e-mail. Any unauthorised copying,
disclosure or distribution of the material in this e-mail is strictly forbidden.




