A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
Arduino in Action
this week in the
General Computing
forum!
A special promo:
Enter your blog post or vote on a blogger to be featured in an upcoming Journal
JavaRanch
»
Java Forums
»
Java
»
JSP
Author
getObject () not returning values
charu latha
Ranch Hand
Joined: Aug 20, 2002
Posts: 67
posted
Oct 24, 2002 04:16:00
0
<%@ page import="java.sql.*,java.io.*" %> <% String stores = (String)session.getAttribute("storeid"); double total = 0; out.print("<html><head>"); out.print("</head><body topmargin=100>"); out.print("<center><table border=1>"); out.print("<tr><th colspan=3><font color=green>YOUR ORDERS </th></tr>"); out.println("<tr><th>Order ID</th><th>Store ID</th><th>Total Value</th></tr>"); Connection con = null; Statement stmt = null; PreparedStatement ps = null; ResultSet rs = null; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc :-o dbc:malldata"); String sql = "SELECT ORDER_ID,STORE_ID,TOT_VALUE FROM [ORDER] WHERE STORE_ID=?"; ps = con.prepareStatement(sql); stmt = con.createStatement(); ps.setString(1,stores); rs = ps.executeQuery(); while (rs.next()) { out.print("<tr><td>"); out.print(rs.getObject(1).toString()); out.println("</td>"); out.println("<td>"); out.println(rs.getObject(2).toString()); out.println("</td>"); out.println("<td>"); out.println(rs.getDouble(3));--------1 out.println("\n"); total = rs.getDouble("TOT_VALUE"); ------2 } } catch (SQLException e) { throw new ServletException("servlet could not display records. " + e); }
When i have just point 1 in my code, it works just fine. point 2 is commented out. If i uncomment 2 and run my code it gives me a no data found error inspite of the database having values. Basically it is not doing the assignment. Any inputs
I agree. Here's the link:
http://zeroturnaround.com/jrebel
- it saves me about five hours per week
subject: getObject () not returning values
Similar Threads
display problem.
Else loop not working
how do i delete multiple records
what could be the reason behind this exception?
Delete Records from MS Access Database
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter