Hi
I'm trying to get an SQL query to work within a JSP file. The JSP file is pulled by a VXML file here is my JSP file code:
<?xml version="1.0"?>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<% boolean success = true; // Always optimistic
String info = "";
String schoolname = request.getParameter("schoolname");
String informationtype = request.getParameter("informationtype");
try {
Class.forName("org.postgresql.Driver");
String connectString = "jdbc:postgresql://localhost:5435/N0176359";
String user = "****";
String password = "*****";
Connection conn = DriverManager.getConnection(connectString, user, password);
Statement st = conn.createStatement();
ResultSet rsvp = st.executeQuery("SELECT * FROM lincolnshire_school_information_new WHERE school_name=\'"+schoolname+"\'");
rsvp.next();
info = rsvp.getString(2);
}catch (ClassNotFoundException e) {
success = false; // something went wrong
}
%>
As you can see I'm trying to insert the value of the variable declared as "schooname" into the end of the SQL query. However when I come to run the jsp file it doesn't work and I get an error "ResultSet not positioned properly". When I put a standard query in (without trying to make it value of the variable it works fine)
Hope that makes sense, and thank you for any help!