• Post Reply 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Retrieve record from db

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai to all,
please help me to retrieve record one by one by click the button.
please check my code.it is not work..
my code is:

<%@ page import="java.sql.*"%>

<SCRIPT LANGUAGE="JavaScript">

function move()
{
var cu = 0
cu = parseInt(document.form1.hidden.value) + 1
document.form1.hidden.value = cu
form1.submit()
}

</SCRIPT>

<FORM NAME="form1" ACTION="query.jsp" >

<%
int cu=1;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con=DriverManager.getConnection("jdbc:odbc:tdsn");
if(request.getParameter("hidden") != null)


cu = Integer.parseInt(request.getParameter("hidden"));

String useri=request.getParameter("D1");

if(useri.equals("SiteType"))
{
String a=request.getParameter("T1");
PreparedStatement ps=con.prepareStatement("SELECT sitetype,buildinght,towerht from tower where sitetype=? and basic.sid=tower.sid");
ps.setString(1,a);
ResultSet rs=ps.executeQuery();

%>
<%
if(rs.next())
{

String r=rs.getString("sitetype");
String d=rs.getString("buildinght");
String f=rs.getString("towerht");


%>
<table>
<tr><%=r%></tr>
<tr><%=d%></tr>
<tr><%=f%></tr>

<input type="button" value="next" onclick="move();">
<input type="hidden" name="hidden" value="<%=cu%>">

<%
}}
%>
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you post an error message or where you think the code does not work?

Also, you misplaced your code tags :-)
 
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool down Bear.. Pradeepa just seems to be a newbie like me.

Hello Pradeepa,

First replace form1.submit() to document.form1.submit();
Next, please correct your CODE tags.
Also please be kind enough to throw some light on what problem youare facing exactly and I would specifically like to know how you are setting T1, D1 etc in the request object, where and all.

Regards
 
Bear Bibeault
Marshal
Posts: 67449
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
    Bookmark Topic Watch Topic
  • New Topic