package contact; import java.io.IOException; import java.io.PrintWriter; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; import oracle.jdbc.pool.OracleDataSource; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class login extends HttpServlet { public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String address="/index.html"; String loginid = request.getParameter("loginid"); String password = request.getParameter("password"); String slogin; // from our database String spassword; // from our database String slastname; String sfirstname; String html=""; int sidnum; int slevel; PrintWriter out = response.getWriter(); if ((loginid!=null) && (loginid.length()!=0)) { String dbtime; String dbUrl = "jdbc:mysql://localhost/contact?user=zdouglas&password=cheese"; String dbClass = "com.mysql.jdbc.Driver"; //String query = "Select * FROM employee where login='"+loginid.trim()+"'"; //String connect_string = "jdbc:oracle:thin:cs4500/cs4500@//localhost:1521/orcl.oracle.com"; String connect_string = "jdbc:oracle:thin:cs4500/cs4500@//localhost:1521/cs4500"; // String query = "select login from user_info"; String login_query = "select password from user_info where login='" + loginid + "'"; // The connection to the database Connection conn=null; try { // See if we need to open the connection to the database if (conn == null) { // Create a OracleDataSource instance and set URL OracleDataSource ods = new OracleDataSource(); ods.setURL(connect_string); // Connect to the databse //out.println("Connecting to " + connect_string + "\n"); conn = ods.getConnection (); //out.println("Connected\n"); } // Create a statement Statement stmt = conn.createStatement (); // Execute the query // out.println("Executing query " + login_query + "\n"); ResultSet rset = stmt.executeQuery (login_query); out.println(""); out.println("
"); out.println("