Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

connection to postgresql

sagrud13sagrud13 Posts: 1Member
i have to connect to Postgresql to populate a listbox... i used the following jsp and html code... but i get an internal error.
I m a newbie in programming... so pls let me kno the error in this code.


<%@ page import="java.sql.*" %>
<%@ page language="java" %>
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page import="java.util.*" %>

PrintWriter pw = response.getWriter();
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String queryText = null;

queryText = "select state_name from state_project"

try {
conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/india_data","postgres","postgres");
stmt = conn.createStatement();
rs = stmt.executeQuery(queryText);
List x= new ArrayList();
request.setAttribute("state_name", rs.getString(2));}
pw.println("state_name" + " "+"<br>");
catch(Exception e) {


my html form is

int i=1;
int nouser
List xlist;%>
nouser = xlist.size();

Sign In or Register to comment.