hi anita..
everything is correct...but try to declare the
variables in the correct place...scope is very
important....
try to declare the Connection & Statement variables in
correct place...& try it ..it will work...
Regards
Jayakumar
--- Anita Lopez <[EMAIL PROTECTED]> wrote:
> Hi all,
> I'm just a beginner and learning that's why i am
> mailing a code which
> is getting connected to servlet but not displaying
> anything.
> i am using msaccess insertion
> plz let me know as to what is wrong.
> Thanks in advance,
> Anita.
>
>
>
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.io.*;
> import java.sql.*;
> public class hospital_servletJdbc extends
> HttpServlet
> {
> Statement smt;
> Connection con1;
> public void doGet(HttpServletRequest
> req,HttpServletResponse res)throws
> ServletException,IOException
> {
> doPost(req,res);
> }
> public void init(ServletConfig con)
> {
> try
> {
> super.init(con);
>
> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
>
>
con1=DriverManager.getConnection("jdbc:odbc:hos","","");
> //smt=con1.createStatement();
> }
> catch(Exception e)
> {}
> }
>
> public void doPost(HttpServletRequest
> req,HttpServletResponse res)throws
> ServletException,IOException
> {
> try
> {
> res.setContentType("Text3/html");
> PrintWriter pw=res.getWriter();
>
> String
> str1=req.getParameter("hospitalname");
> String str2=req.getParameter("category");
> String
> str3=req.getParameter("autho_person");
> String str4=req.getParameter("regis_date");
> String str5=req.getParameter("timings");
> String str6=req.getParameter("add1");
> String str7=req.getParameter("add2");
> String str8=req.getParameter("add3");
> String str9=req.getParameter("city");
> String str10=req.getParameter("city1");
> String str11=req.getParameter("state");
> String str12=req.getParameter("pin");
> String str13=req.getParameter("phone");
> String str14=req.getParameter("fax_no");
> String str15=req.getParameter("email");
> String str16=req.getParameter("linkpage");
> String str17=req.getParameter("no_beds");
> String str18=req.getParameter("facilites");
>
>
>
> smt=con1.createStatement();
> String sqlstr1="insert into hospital1 values
>
>
('"+str1+"','"+str2+"','"+str3+"','"+str4+"','"+str5+"','"+str6+"','"+str7+"','"+str8+"','"+str9+"','"+str10+"','"+str11+"','"+str12+"','"+str13+"','"+str14+"','"+str15+"','"+str16+"','"+str17+"','"+str18+"')";
>
> int i=smt.executeUpdate(sqlstr1);
>
> pw.println("<html><body>");
> pw.println(" thanx for using our site<br>");
> pw.println("</body></html>");
> pw.close();
> }
> catch(Exception e)
> {
> }
> }
> }
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED]
> and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives:
>
http://archives.java.sun.com/archives/servlet-interest.html
> Resources:
>
http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help:
http://www.lsoft.com/manuals/user/user.html
__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html