0

So heres my index page.

<form action="worker.jsp">
  <input type="text" name="count"></input>
</form>

and heres my worker.jsp.

<jsp:useBean id="ff" class="my.dbController" scope="page"/>
String count = (request.getParameter("count"));
ff.queryTest(count)

and heres the java dbController file.

String query = "Select * from table limit ?"
PreparedStatement ps = conn.prepareStatement(query);
ps.setString(1, x);
ps.executeUpdate();

Would this be possible? I've been trying it this way but it keeps returning 0 data.

Edit: I was able to fix it, i had one error in my .jsp files. Thanks anyway

Nik
  • 43
  • 1
  • 7

2 Answers2

1

You are doing an executeUpdate when you should do an executeQuery.

Roger Gustavsson
  • 1,689
  • 10
  • 20
0

1)You've already prepared the statement so executeUpdate() will not work. 2)The limit parameter accepts int. No need to pass a string to it.

Do

ps.setInt(1,limit);
ps.executeUpdate(query);

Always have a proper naming convention instead of naming variables like x,y :)