Servlet with Mysql database : I have the following Servlet code with mysql database.I have written
query for displaying source to destination cost that will be
retrieved from database.But how to write a query that will return same cost when i reverse my source and destination in the select box?

    import java.io.IOException;
    import java.io.PrintWriter;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.Statement;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    /**
    * Servlet implementation class Test3
    */
    @WebServlet("/Test3")
    public class Test3 extends HttpServlet {
	private static final long serialVersionUID = 1L;
    protected void doPost(HttpServletRequest request,
    HttpServletResponse response) throws ServletException, IOException 
    {
	RequestDispatcher rd = request.getRequestDispatcher("source.jsp"); 
	rd.include(request, response);
	try
	{
	Class.forName("com.mysql.jdbc.Driver");
    //conn code//
    Statement stmt=(Statement)con.createStatement();
	PrintWriter out=response.getWriter();
	String name=request.getParameter("sel");
	String name1=request.getParameter("sel1");
	String sql="select * from USER where (source='"+name+"' AND
    destination='"+name1+"')";
	ResultSet rs=stmt.executeQuery(sql);
	while(rs.next())
    {
	out.println("<br>");
    out.println(rs.getString("source"));
	out.println(rs.getString("destination"));
    out.println("<br>");
    out.println("Cost:"+rs.getInt("cost"));
    }
    //method may be include or forward
	}
	catch(Exception e)
	{
	System.out.println("Error:"+e.getMessage());
	}
	}
	}
	

	
	



