Thank u.
it's working.but,i've another question.
I want to create a database that stores information about customer choices.Like,my html page contains a choice of text books.Corresponding to the selection the user made, i want to insert the isbn number of the book in the database.
If i try to do that iam getting an error message saying that"no db".
please check this out.
import java.io.*;
import javax.swing.*;
import java.util.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class postparametersservlet extends HttpServlet
{
private Connection connection;
private JTable table;
String url="jdbc
dbc:book";
public void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
{
String isbn[]={"1234","34234","45362","78960"};
String name[]={"java","c++","c","oracle"};
String data=request.getParameter("data");
Cookie c=new Cookie("java","isbn");
response.setContentType("text/html");
PrintWriter pw=response.getWriter();
response.addCookie(c);
pw.println("<html><head><title>");
pw.println("cod cookies");
pw.println("</title></head><body>");
pw.println(data);
pw.println("</body></html>");
pw.close();
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connection=DriverManager.getConnection(url);
}
catch(ClassNotFoundException cnf)
{
System.out.println("no class");
}
catch(SQLException sqle)
{
System.out.println("no db");
}
try
{
Statement s=connection.createStatement();
String q;
if(data.equals("java"))
{
q="insert into choices(bookname, isbnnumber)values(data,isbn[0])";
connection.nativeSQL(q);
int result=s.executeUpdate(q);
if(result==1)
System.out.println("successfull");
else
System.out.println("unsuccessfull");
s.close();
}
}
catch(SQLException sqle)
{
System.out.println("failed access");
}
}
}