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 |
|
|
cetan2
Posts: 7
|
Posted: 03/25/2009, 9:34 PM |
|
What is this about ? You need help or you sharing some sample code !
|
|
|
|