i'm trying to access some data from
my database but i have A strange behavior and hope to help me to understand
what is happening
when i try to retrieve column data form DB and print it
it will be printed
but when i try to assign it to a String
i get this exception "NO Data Found"
Query=" select * from CPM_DEST";
st = conn.createStatement();
System.out.println(rs.getString("DESTNAME")); //printwith no problem
String x=(String)rs2.getString("DESTNAME");//here i get the exception
Welcome to the JavaRanch.
We're a friendly group, but we do require members to have valid display names.
Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.
Please edit your profile and correct your display name since accounts with invalid display names get deleted, often without warning
Originally posted by David O'Meara:
You can only read each value from the Resultset once, after that nothing is guaranteed. It's in the API somewhere but I'd have to go look.
Yeah Dave i got you point inside jdbc basic on java.sun.com
"each column should be read only once"
here is a URL http://java.sun.com/docs/books/tutorial/jdbc/basics/retrieving.html look at last line in first paragraph inside the heading of Using the getXXX Methods
The ResultSet interface provides getter methods (getBoolean, getLong, and so on) for retrieving column values from the current row. Values can be retrieved using either the index number of the column or the name of the column. In general, using the column index will be more efficient. Columns are numbered from 1. For maximum portability, result set columns within each row should be read in left-to-right order, and each column should be read only once.