1. Create a website for an e-commerce company selling only the electronic goods. The website uses divisions and an external CSS file. Every page of the website is divided into four divisions namely – HEADING, FOOTER, MENU and CONTENT. (40 Marks) Solution: Mystyle.css
www.onlinecode.in Provided By : bUNK iT } publicvoid setPassword(String password) { this.password = password; } }
UserDao.java:-
Page | 11
package com.bunkit.bca4.dao; import java.sql.*; import org.apache.log4j.Logger; public class UserDao extends AbstractDao { Logger logger=Logger.getRootLogger(); //Method to save the user public void save(User user) throws Exception { //Connection is obtained. Connection con=getConnection();//super class method //Statement object is created to execute the query. PreparedStatement stmt=con.prepareStatement( "insert into UserMaster (mailid,password)" + " values(?,?,?)"); //set the value of parameters. stmt.setString(2,user.getMailId()); stmt.setString(3,user.getPassword()); //execute the query stmt.executeUpdate(); //close the connection con.close(); } //Method to update the user public void resetPassword(String p,String mid) throws Exception { //Connection is obtained. Connection con=getConnection();//super class method //Statement object is created to execute the query. PreparedStatement stmt=con.prepareStatement( "update usermaster set password=? where mailId=?"); //set the value of parameters. stmt.setString(1,p); stmt.setString(2,mid); //execute the query stmt.executeUpdate(); //close the connection logger.info("sucessfully reset your password "); con.close(); } //Method to delete the user public void delete(int userId) throws Exception { //Connection is obtained. Connection con=getConnection();//super class method //Statement object is created to execute the query.
Prepared by : IGNOU ROCK
www.onlinecode.in Provided By : bUNK iT PreparedStatement stmt=con.prepareStatement( "delete from UserMaster where id=?"); //set the value of parameters. stmt.setInt(1, userId); //execute the query stmt.executeUpdate(); //close the connection con.close(); } //Method to load a user using id public User getById(int userId) throws Exception { User user=null; //Connection is obtained. Connection con=getConnection();//super class method //Statement object is created to execute the query. PreparedStatement stmt=con.prepareStatement( "select * from UserMaster where userId=?"); //set the value of parameters. stmt.setInt(1, userId); //execute the query ResultSet rset=stmt.executeQuery(); //read the result of select query if(rset.next())//if user is found. { user=new User(); //store record data in object user.setId(rset.getInt(1)); user.setMailId(rset.getString(2)); user.setPassword(rset.getString(3)); } //close the connection con.close(); //return the user object return user; } //Method to find user using mailId and password public boolean findUser(User user) throws Exception { boolean flag=false; //Connection is obtained. Connection con=getConnection();//super class method //Statement object is created to execute the query. PreparedStatement stmt=con.prepareStatement( "select * from usermaster where mailId=? and password=?"); //set the value of parameters. stmt.setString(1, user.getMailId()); stmt.setString(2, user.getPassword()); //execute the query ResultSet rset=stmt.executeQuery(); //read the result of select query if(rset.next())//if user is found. { flag=true; //store record data in object user.setId(rset.getInt(1)); }
Prepared by : IGNOU ROCK
Page | 12
www.onlinecode.in Provided By : bUNK iT //close the connection con.close(); //return the user object return flag; } //find mail_id public User findMailId(String mailid) throws Exception { User user=new User(); //Connection is obtained. Connection con=getConnection();//super class method //Statement object is created to execute the query. logger.info(":::::user email id is "+mailid); PreparedStatement stmt=con.prepareStatement("select * from usermaster where mailId=?"); //set the value of parameters. stmt.setString(1, mailid); //execute the query ResultSet rset=stmt.executeQuery(); //read the result of select query if(rset.next())//if user is found. { //store record data in object user.setId(rset.getInt(1)); user.setMailId(rset.getString(2)); user.setPassword((rset.getString(3))); } //close the connection con.close(); //return the user object return user; } }
Prepared by : IGNOU ROCK
Page | 13
BCSL-057.pdf
divisions and an external CSS file. Every page of the website ... ... Displaying BCSL-057.pdf. Page 1 of ...