import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class connToHr extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
{
PrintWriter out=res.getWriter();
try
{
String conURL="jdbc:oracle:thin:@localhost:1521:orcl";
String conUSER="HR";
String conPASSWORD="HR";
String uniDriver="sun.jdbc.odbc.JdbcOdbcDriver";
Driver d=(Driver)Class.forName(uniDriver).newInstance();
Connection con=DriverManager.getConnection(conURL,conUSER,conPASSWORD);
Statement stmt=con.createStatement();
ResultSet rs;
rs= stmt.executeQuery("SELECT * FROM EMPLOYEES");
while(rs.next())
{
out.println("<HTML><BODY><H1>THE EMPLOYEE DETAILS ARE</H1><TABLE>");
out.println("<TR><TD>"+rs.getString("EMPLOYEE_ID")+"</TD><TD>"+
rs.getString("FIRST_NAME")+"</TD><TD>"+rs.getString("SALARY")+"</TD></TR>");
out.println("</TABLE>");
}
}catch(Exception e){out.println(e.getMessage());}
}
}
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class connToHr extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
{
PrintWriter out=res.getWriter();
try
{
String conURL="jdbc:oracle:thin:@localhost:1521:orcl";
String conUSER="HR";
String conPASSWORD="HR";
String uniDriver="sun.jdbc.odbc.JdbcOdbcDriver";
Driver d=(Driver)Class.forName(uniDriver).newInstance();
Connection con=DriverManager.getConnection(conURL,conUSER,conPASSWORD);
Statement stmt=con.createStatement();
ResultSet rs;
rs= stmt.executeQuery("SELECT * FROM EMPLOYEES");
while(rs.next())
{
out.println("<HTML><BODY><H1>THE EMPLOYEE DETAILS ARE</H1><TABLE>");
out.println("<TR><TD>"+rs.getString("EMPLOYEE_ID")+"</TD><TD>"+
rs.getString("FIRST_NAME")+"</TD><TD>"+rs.getString("SALARY")+"</TD></TR>");
out.println("</TABLE>");
}
}catch(Exception e){out.println(e.getMessage());}
}
}
Comments
Post a Comment