Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Retrieve record from db  RSS feed

 
pradeepa sakthi
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("jdbcdbc: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%>">

<%
}}
%>
 
Sebastian Janisch
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 :-)
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
 
Himanshu Kansal
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
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!