I thought the same , but after debugging look at down my piece of code....
try{
rsmd = rs.getMetaData();
numCols = rsmd.getColumnCount();
for (i=1; i<=numCols; i++) {
out.println("<td><H3>" + rsmd.getColumnLabel(i) +
"</H3></td>");
}
k= 1; //---> printing
while (rs.next()) {
k=2; //---> not printing
for (i=1; i<=numCols; i++) {
ctype = rsmd.getColumnType(i);
switch(ctype) {
case Types.DATE:
java.sql.Date date = rs.getDate(col);
---
case Types.TIMESTAMP:
java.sql.Timestamp timestamp =
rs.getTimestamp(col);
case Types.VARCHAR:
String str = rs.getString(col);
case Types.SMALLINT:
short smallint = rs.getShort(col);
}
}
}catch (SQLException ex) {
out.println("the k value =:"+ k);
out.println("*** SQLException caught
***dispResultset<p>");
while (ex != null) {
out.println("Message: " + ex.getMessage() +
"<br>");
ex = ex.getNextException();
}
}
So if u observe i am trying to print the value of variable 'K' in catch
block...its printing only K=1 ..
as i assigned k=1 before while loop and immediately after that i assigned
K=2 but its not printing 2. ...i am wondering what could be the reason..
I was able to same query for some other data...same table, same columns...i
was able to retrieve some data and some not....
-----Original Message-----
From: Simon Christian [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 05, 1999 10:34 AM
To: [EMAIL PROTECTED]
Subject: Re: while(rs.next())
At a guess from the error message, the problem is not in fact with
rs.next(),
but are you attempting to retrieve an int from the ResultSet on a following
line? e.g. int id = rs.getInt("id");
If the column you are attempting to retrieve data for is not of integer
type, it
could cause an error while converting at this stage. Check carefully.
- simon
"PATIBANDA, SRIKANTH" wrote:
> Hi,
>
> I am having some problem with rs.next().
> I am able to execute the query,
> statement = connection.createStatement();
> query = "Select * from XYZ";
> rs = statement.executeQuery(query);
>
> ResultSetMetaData rsmd = rs.getMetaData();
> numCols = rsmd.getColumnCount();
>
> for (i=1; i<=numCols; i++) {
> out.println("<td><H3>" + rsmd.getColumnLabel(i) + "</H3></td>");
> }
>
> My program is working till here very fine. I was able to display the
> columnlabel, the coulumn count and etc.
> The problem come now...in the while loop...
>
> while (rs.next()) {
>
> Its not that there is no data...there is data in the oracle database. When
i
> do directly from SQL> prompt works fine..with the same query its not
working
> with JDBC.
>
> At this point iam getting this following error...
>
> "ORA-01455: converting column overflows integer datatype."
>
> I debugged and i am sure the problem is with rs.next()...
> Does anyone know about this problem..what could be the solution...
> I really appreciate anyone help.
> ThankYou
> Srikanth Patibanda
> IT Specialist
> Entergy Corporation
> Ph: (W)504-576-5444
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html