shilu2 0 Newbie Poster

Hi All,
Can you please help me how to create user defined function for database connectivity and return values to anather servlet. I have tried following code but it indicates error can not find symbol

package controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.*;
import java.util.*;
import java.util.ArrayList;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ConnectivityServlet extends HttpServlet {
    HttpServletRequest request;
    HttpServletResponse resonse;

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            Class.forName("com.mysql.jdbc.Driver");
            Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/store?user=shilpa&password=password");

        }catch(ClassNotFoundException ce){
        }catch(SQLException se){
        } finally {            
            out.close();
        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">


    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html");
        PrintWriter out=response.getWriter();


        }
     public String connectFunction(Connection con) throws IOException{
         try{
            HttpServletRequest request=null;
            HttpServletResponse response=null;
            response.setContentType("text/html");
            PrintWriter out=response.getWriter();
            ArrayList list=new ArrayList();

            String query="select name from login";
            Statement st1=con.createStatement();
            ResultSet rs=st1.executeQuery(query);
            while (rs.next()) {
                list.add(rs.getString("name"));          
             }
            return(response.setAttribute("data", list));
         }catch(Exception e){} 
      }       

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }


    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>
}

Thank you