CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Java

 Search engine java code

Print topic Send  topic

Author Message
bharathtele

Posts: 1
Posted: 10/16/2008, 1:36 AM

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.io.*;
import java.sql.Driver.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.lang.String;






/** Very simplistic servlet that generates plain text.
* <P>
* Taken from Core Servlets and JavaServer Pages
* from Prentice Hall and Sun Microsystems Press,
* http://www.coreservlets.com/.
* © 2000 Marty Hall; may be freely used or adapted.
*/

public class search extends HttpServlet
{

public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException
{
PrintWriter out = response.getWriter();
Connection con=null;
ResultSet rs=null;
PreparedStatement pstmt=null;

Statement stmt=null;

String s="jdbc:mysql://localhost:3306/searchengine?user=root &password=" ;

String item= request.getParameter("item");
String[] ss=item.split(" ");
int len=ss.length;
//out.print(ss.length);

try{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection(s);
}
catch(Exception e){ System.out.print(e); }

if(con!=null)
{
int i=0;
while(i<len)
{
try {


String st="select * from section where head like '%"+ss+"%' ";
//out.println(st);
pstmt=con.prepareStatement(st);

rs=pstmt.executeQuery();
if(rs.next()){
String sas=rs.getString("description");
out.println(sas);
out.println();
}

} catch (SQLException ex) {
ex.printStackTrace();
}



i++;
}

}

}

}

_________________
for more information u can send to bharathtele@gmail.com
View profile  Send private message
cetan2

Posts: 7
Posted: 03/25/2009, 9:34 PM

What is this about ? You need help or you sharing some sample code !
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright 2003-2004 by UltraApps.com  and YesSoftware, Inc.