About database connection string in oracle 10g with servlet
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Bandana_Shaw
Posted On:   Monday, September 14, 2009 12:10 PM

=========================== LOGIN.HTML =============================== User Name: Password: ============================================================== LOGIN.JAVA (URL-/LOGIN)THIS IS THE SERVLET ...HERE rs.executeQuery("SELECT * FROM LOGIN ")IS NOT WORKIING ===================================================== package pack; import java.io.*; import java.sql.*; import javax.servlet.*;    More>>

===========================
LOGIN.HTML
===============================




















User Name:
Password:





==============================================================
LOGIN.JAVA (URL-/LOGIN)THIS IS THE SERVLET ...HERE rs.executeQuery("SELECT * FROM LOGIN ")IS NOT WORKIING
=====================================================
package pack;

import java.io.*;

import java.sql.*;

import javax.servlet.*;

import javax.servlet.http.*;



public class login extends HttpServlet

{


protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException

{

int i=0;

String name=request.getParameter("user");

String password=request.getParameter("pass");


response.setContentType("text/html");

PrintWriter p=response.getWriter();


p.print(" ");

try {

Class.forName("oracle.jdbc.driver.OracleDriver");

Connection c=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:oracle","scott","tiger");

Statement st=c.createStatement();


String s="select * from login";

//String s="delete from login where pass=1";

st.executeUpdate(s);

ResultSet rs=st.executeQuery(s);

p.println("Welcome12 ");

while(rs.next())

{p.println("Welcome 22");

String user=rs.getString(1);

String pass=rs.getString(2);


if(name .equals(user) && password .equals(pass))

{

p.println("Welcome13 "+name);

i=1;

}

}


if(i==0)

{
p.print("Enter correct username");

}

c.close();

}

catch(Exception e){}

p.print(" ");



}



}
   <<Less
About | Sitemap | Contact