// Static initializer block to load the JDBC Driver static {

Size: px
Start display at page:

Download "// Static initializer block to load the JDBC Driver static {"

Transcription

1 package daos; import java.sql.connection; import java.sql.drivermanager; import java.sql.sqlexception; public class ConnectionHandler { private static final String URL="jdbc:mysql://localhost/g12"; private static final String USER="g12"; private static final String PASSWORD = ""; // Static initializer block to load the JDBC Driver static { try { //DriverManager.registerDriver(new Driver()); Class.forName("com.mysql.jdbc.Driver"); catch(exception e){ throw new IllegalStateException("Unable to load JDBC driver for MySQL 5.0", e); public static Connection getconnection() throws DAOException{ try { return DriverManager.getConnection(URL, USER, PASSWORD); catch(sqlexception e){ throw new DAOException("Unable to create connections to the database.", e);

2 package daos; public class DAOException extends Exception { public DAOException(String str){ super(str); public DAOException(String str, Exception cause){ super(str, cause); package daos; import java.sql.connection; import java.sql.drivermanager; import java.sql.sqlexception; public class ConnectionHandler { private static final String URL="jdbc:mysql://localhost/g12"; private static final String USER="g12"; private static final String PASSWORD = ""; // Static initializer block to load the JDBC Driver static { try { //DriverManager.registerDriver(new Driver()); Class.forName("com.mysql.jdbc.Driver"); catch(exception e){ throw new IllegalStateException("Unable to load JDBC driver for MySQL 5.0", e); public static Connection getconnection() throws

3 DAOException{ try { return DriverManager.getConnection(URL, USER, PASSWORD); catch(sqlexception e){ throw new DAOException("Unable to create connections to the database.", e); package daos; import java.io.file; import java.sql.connection; import java.sql.date; import java.sql.preparedstatement; import java.sql.resultset; import java.sql.sqlexception; import java.text.*; import java.util.*; import pojo.event; import pojo.restaurant; public class EventDAO { private int thisday; private int thisyear; private int newid; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); public EventDAO() { public EventDAO(int index) { newid = index; public ArrayList<Event> UpcomingEvents() throws

4 DAOException{ ArrayList<Event> upcomingevents = new ArrayList<Event>(); Connection conn = ConnectionHandler.getConnection(); DAOException edao = null; Event event = null; try { PreparedStatement stmt = conn.preparestatement("select distinct title, name, eventdate, eventtime from g12.eventvenue join g12.event join g12.restaurant where time = eventtime and date = eventdate and idrestaurant = venuerestaurant order by eventdate asc limit 9;"); ResultSet res = stmt.executequery(); while(res.next()){ event = new Event(); event.settitle(res.getstring("title")); event.setvenue(res.getstring("name")); event.settime(res.getstring("eventtime")); event.setdate(res.getstring("eventdate")); upcomingevents.add(event); catch(sqlexception e){ edao = new DAOException("Unable to submit update query for item data.", e); throw edao; finally { // Close the DB connection try { conn.close(); catch (SQLException e) { if (edao == null){ throw new DAOException("Unable to close connection after successful query."); else {

5 throw new DAOException("Unable to close connection after DAPException. SQL message: " + e.tostring(), edao); return upcomingevents; "static-access", "deprecation" ) public ArrayList<Event> queryevents() throws DAOException ArrayList<Event> events = new ArrayList<Event>(); Calendar cal = Calendar.getInstance(); thisday = cal.get(calendar.day_of_year); thisyear = cal.get(calendar.year); Connection conn = ConnectionHandler.getConnection(); DAOException edao = null; try { PreparedStatement stmt = conn.preparestatement("select r.name, title, time, date" + " from g12.eventvenue, g12.restaurant as r, g12.event" + " where venuerestaurant = idrestaurant" + " and eventtime = event.time" + " and eventdate = event.date" + " and eventdate between curdate() and (curdate()+7);"); ResultSet res = stmt.executequery(); while(res.next()){ Event event = new Event(); event.settitle(res.getstring("title")); event.setvenue(res.getstring("r.name")); event.settime(res.getstring("time")); event.setdate(res.getstring("date")); events.add(event);

6 stmt.close(); catch (SQLException e){ edao = new DAOException("Unable to submit query for student data.", e); throw edao; finally{ // Close the DB connection try { conn.close(); catch (SQLException e) { if (edao == null){ throw new DAOException("Unable to close connection after successful query."); else { throw new DAOException("Unable to close connection after DAPException. SQL message: " + e.tostring(), edao); return events; public Event findevent(string id) throws DAOException{ Event result = null; Connection conn = ConnectionHandler.getConnection(); DAOException edao = null; Date sqldate = new java.sql.date(0); String[] fields = id.split("\\s"); try { sqldate = new java.sql.date((sdf.parse(fields[0])).gettime()); catch (ParseException e1) { e1.printstacktrace(); try { PreparedStatement stmt = conn.preparestatement("select * FROM g12.event where date =? and time =?;");

7 stmt.setstring(1, sqldate.tostring()); stmt.setstring(2, fields[1]); ResultSet res = stmt.executequery(); if (res.next()){ result = new Event(); result.settime(res.gettime("time").tostring()); result.setdate(res.getdate("date").tostring()); result.settitle(res.getstring("title")); result.setdescription(res.getstring("description")); stmt.close(); catch (SQLException e){ edao = new DAOException("Unable to submit query for event data.", e); throw edao; finally{ // Close the DB connection try { conn.close(); catch (SQLException e) { if (edao == null){ throw new DAOException("Unable to close connection after successful query."); else { throw new DAOException("Unable to close connection after DAOException. SQL message: " + e.tostring(), edao); return result; public void addevent(event event) throws DAOException { Connection conn = ConnectionHandler.getConnection(); DAOException edao = null;

8 try { PreparedStatement stmt = conn.preparestatement("insert event(eventid,time,date,description) VALUES(?,?,?,?)"); stmt.setint(1, newid); stmt.setstring(2, event.gettime().tostring()); stmt.setstring(3, event.getdate().tostring()); stmt.setstring(4, event.gettitle()); stmt.setstring(5, event.getdescription()); stmt.executeupdate(); // Close the statement stmt.close(); catch (SQLException e) { edao = new DAOException( "Unable to submit update query for student data.", e); throw edao; finally { // Close the DB connection try { conn.close(); catch (SQLException e) { if (edao == null) { throw new DAOException( "Unable to close connection after successful query."); else { throw new DAOException( "Unable to close connection after DAPException. SQL message: " + e.tostring(), edao);

9 package daos; import java.io.file; import java.sql.connection; import java.sql.preparedstatement; import java.sql.resultset; import java.sql.sqlexception; import java.sql.statement; import pojo.registereduser; public class RegisteredUserDAO { public RegisteredUserDAO(){ public RegisteredUser finduser(string username) throws DAOException { Connection conn = ConnectionHandler.getConnection(); DAOException edao = null; RegisteredUser user = null; try { PreparedStatement stmt = conn.preparestatement("select * FROM g12.registereduser where username =?"); stmt.setstring(1, username); ResultSet res = stmt.executequery(); if(res.next()){ user = new RegisteredUser(); user.set (res.getstring(" ")); user.setusername(res.getstring("username")); user.setname(res.getstring("name")); //user.setlocation(res.getstring("location")); user.setphonenumber(res.getstring("phone"));

10 user.setpassword(res.getstring("password")); catch(sqlexception e){ edao = new DAOException("Unable to submit update query for item data.", e); throw edao; finally { // Close the DB connection try { conn.close(); catch (SQLException e) { if (edao == null){ throw new DAOException("Unable to close connection after successful query."); else { throw new DAOException("Unable to close connection after DAPException. SQL message: " + e.tostring(), edao); return user; public int addregistereduser(registereduser user) throws DAOException{ Connection conn = ConnectionHandler.getConnection(); DAOException edao = null; ResultSet genkeys = null; int newid = 0; try { PreparedStatement stmt = conn.preparestatement("insert into g12.registereduser ( , username, password, name, location, phone) VALUES(?,?,?,?,?,?)", Statement.RETURN_GENERATED_KEYS);

11 stmt.setstring(1, user.get ()); stmt.setstring(2, user.getusername()); stmt.setstring(3, user.getpassword()); stmt.setstring(4, user.getname() +" "+ user.getlastname()+" "+ user.getmaidenname()); stmt.setstring(5, user.getcity()+ ", " + user.getcountry()); stmt.setstring(6, user.getphonenumber()); stmt.executeupdate(); genkeys = stmt.getgeneratedkeys(); if (genkeys.next()){ newid = genkeys.getint(1); user.setregistereduserid(newid); else { throw new DAOException("Unable to acquire new id for the record being inserted."); stmt.close(); catch(sqlexception e){ edao = new DAOException("Unable to submit update query for item data.", e); throw edao; finally { // Close the DB connection try { conn.close(); catch (SQLException e) { if (edao == null){ throw new DAOException("Unable to close connection after successful query."); else { throw new DAOException("Unable to close connection after DAPException. SQL message: " + e.tostring(), edao);

12 return newid; package daos; import java.io.file; import java.sql.connection; import java.sql.date; import java.sql.preparedstatement; import java.sql.resultset; import java.sql.sqlexception; import java.sql.statement; import java.sql.time; import java.util.arraylist; import pojo.restaurant; public class RestaurantDAO { public RestaurantDAO(){ public ArrayList<Restaurant> topratedrestaurant() throws DAOException{ ArrayList<Restaurant> toprated = new ArrayList<Restaurant>(); Connection conn = ConnectionHandler.getConnection(); DAOException edao = null; Restaurant rest = null; try { PreparedStatement stmt = conn.preparestatement("select g12.restaurant.idrestaurant, g12.restaurant.name, g12.restaurant.cuisine, avg(overall) as avgoverall from (select * from g12.userreview where ratedrestaurant in (select

13 ratedrestaurant from g12.userreview group by ratedrestaurant)) as d1 join g12.restaurant where g12.restaurant.idrestaurant = d1.ratedrestaurant group by ratedrestaurant order by avgoverall desc limit 6;"); ResultSet res = stmt.executequery(); while(res.next()){ int rid = Integer.parseInt(res.getString("idRestaurant")); rest = new Restaurant(); rest.setrestaurantid(rid); rest.setname(res.getstring("name")); rest.setcuisine(res.getstring("cuisine")); rest.setrating(res.getstring("avgoverall")); toprated.add(rest); catch(sqlexception e){ edao = new DAOException("Unable to submit update query for item data.", e); throw edao; finally { // Close the DB connection try { conn.close(); catch (SQLException e) { if (edao == null){ throw new DAOException("Unable to close connection after successful query."); else { throw new DAOException("Unable to close connection after DAPException. SQL message: " + e.tostring(), edao); return toprated;

14 public Restaurant findrestaurant(int id) throws DAOException { Connection conn = ConnectionHandler.getConnection(); DAOException edao = null; Restaurant rest = null; try { PreparedStatement stmt = conn.preparestatement("select * FROM g12.restaurant, g12.userreview" + " where idrestaurant =?" + " and idrestaurant = ratedrestaurant"); stmt.setint(1, id); ResultSet res = stmt.executequery(); if(res.next()){ rest = new Restaurant(); rest.setrestaurantid(res.getint("idrestaurant")); rest.setname(res.getstring("name")); rest.setlocation(res.getstring("location")); rest.setaddress(res.getstring("address")); rest.setaddress1(res.getstring("address2")); rest.setprice(res.getstring("pricerange")); rest.setcuisine(res.getstring("cuisine")); rest.settype(res.getstring("type")); rest.setphone(res.getstring("phone")); rest.setwebsite(res.getstring("website")); rest.sethours(res.getstring("hours")); rest.setdays(res.getstring("days")); rest.setdelivery(res.getstring("delivery")); rest.setlimitations(res.getstring("limitations")); rest.setseating(res.getstring("seatingoutside")); rest.setreservations(res.getstring("reservations")); rest.setfax(res.getstring("fax")); rest.setother(res.getstring("other"));

15 rest.setrating(res.getstring("overall")); rest.setsetting(res.getstring("setting")); rest.setquality(res.getstring("quality")); rest.setservice(res.getstring("service")); catch(sqlexception e){ edao = new DAOException("Unable to submit update query for item data.", e); throw edao; finally { // Close the DB connection try { conn.close(); catch (SQLException e) { if (edao == null){ throw new DAOException("Unable to close connection after successful query."); else { throw new DAOException("Unable to close connection after DAPException. SQL message: " + e.tostring(), edao); return rest; public int addrestaurant(restaurant rest) throws DAOException{ Connection conn = ConnectionHandler.getConnection(); DAOException edao = null; ResultSet genkeys = null; int newid = 0; try { PreparedStatement stmt =

16 conn.preparestatement("insert into g12.restaurant (name,location,phone,fax,website,hours,days,cuisine,seatingoutsid e, reservations,delivery,limitations,other,address,address2,priceran ge,type) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", Statement.RETURN_GENERATED_KEYS); stmt.setstring(1, rest.getname()); stmt.setstring(2, rest.getlocation()); stmt.setstring(3, rest.getphone()); stmt.setstring(4, rest.getfax()); stmt.setstring(5, rest.getwebsite()); stmt.setstring(6, rest.gethours()); stmt.setstring(7, rest.getdays()); stmt.setstring(8, rest.getcuisine()); stmt.setstring(9, rest.getseating()); stmt.setstring(10, rest.getreservations()); stmt.setstring(11, rest.getdelivery()); stmt.setstring(12, rest.getlimitations()); stmt.setstring(13, rest.getother()); stmt.setstring(14, rest.getaddress()); stmt.setstring(15, rest.getaddress1()); stmt.setstring(16, rest.getprice()); stmt.setstring(17, rest.gettype()); stmt.executeupdate(); genkeys = stmt.getgeneratedkeys(); // if (genkeys.next()){ // newid = genkeys.getint(1); // // // // rest.setrestaurantid(newid); // // // else { // throw new DAOException("Unable to acquire new id for the record being inserted."); // stmt.close();

17 catch(sqlexception e){ edao = new DAOException("Unable to submit update query for item data.", e); throw edao; finally { // Close the DB connection try { conn.close(); catch (SQLException e) { if (edao == null){ throw new DAOException("Unable to close connection after successful query."); else { throw new DAOException("Unable to close connection after DAPException. SQL message: " + e.tostring(), edao); return newid; package daos; import java.io.file; import java.sql.connection; import java.sql.preparedstatement; import java.sql.resultset; import java.sql.sqlexception; import java.util.arraylist; import pojo.restaurant; import pojo.review; public class ReviewDAO { private int newid; public ReviewDAO() {

18 public ReviewDAO(int index) { newid = index; public Review findreview(int id) throws DAOException{ Review result = null; Connection conn = ConnectionHandler.getConnection(); DAOException edao = null; try { PreparedStatement stmt = conn.preparestatement("select * FROM item INNER JOIN video ON item.itemid=video.itemid where item.itemid =?"); stmt.setlong(1, id); ResultSet res = stmt.executequery(); if (res.next()){ result = new Review(); stmt.close(); catch (SQLException e){ edao = new DAOException("Unable to submit query for student data.", e); throw edao; finally{ // Close the DB connection try { conn.close(); catch (SQLException e) { if (edao == null){ throw new DAOException("Unable to close connection after successful query."); else { throw new DAOException("Unable to close connection after DAOException. SQL message: " +

19 e.tostring(), edao); // Returns the student return result; { public void addreview(review review) throws DAOException Connection conn = ConnectionHandler.getConnection(); DAOException edao = null; try { PreparedStatement stmt = conn.preparestatement("insert into g12.userreview(service,quality,setting,overall, comment, rater, ratedrestaurant, date) VALUES(?,?,?,?,?,?,?, curdate())"); stmt.setdouble(1, review.getservicescore()); stmt.setdouble(2, review.getfoodqualityscore()); stmt.setdouble(3, review.getsettingscore()); stmt.setdouble(4, review.gettotalscore()); stmt.setstring(5, review.getcomment()); stmt.setstring(6, review.getreviewer()); stmt.setint(7, review.getrestaurantid()); stmt.executeupdate(); // Close the statement stmt.close(); catch (SQLException e) { edao = new DAOException( "Unable to submit insert query for review.", e); throw edao; finally { // Close the DB connection try { conn.close(); catch (SQLException e) { if (edao == null) { throw new DAOException(

20 "Unable to close connection after successful query."); else { throw new DAOException( "Unable to close connection after DAPException. SQL message: " + e.tostring(), edao); public ArrayList<Review> topreview(integer restaurantid) throws DAOException{ ArrayList<Review> toprated = new ArrayList<Review>(); Connection conn = ConnectionHandler.getConnection(); DAOException edao = null; Restaurant rest = null; try { PreparedStatement stmt = conn.preparestatement("select * from g12.restaurant join g12.userreview " + "where idrestaurant = ratedrestaurant " + "and idrestaurant =? " + "order by date desc limit 3;"); stmt.setint(1, restaurantid); ResultSet res = stmt.executequery(); while(res.next()){ Review rev = new Review(); rev.setreviewer(res.getstring("rater")); rev.setdate(res.getstring("date")); rev.setcomment(res.getstring("comment")); toprated.add(rev); catch(sqlexception e){

21 edao = new DAOException("Unable to submit update query for item data.", e); throw edao; finally { // Close the DB connection try { conn.close(); catch (SQLException e) { if (edao == null){ throw new DAOException("Unable to close connection after successful query."); else { throw new DAOException("Unable to close connection after DAPException. SQL message: " + e.tostring(), edao); return toprated; public ArrayList<Review> queryreviews(integer restaurantid) throws DAOException{ ArrayList<Review> toprated = new ArrayList<Review>(); Connection conn = ConnectionHandler.getConnection(); DAOException edao = null; Restaurant rest = null; try { PreparedStatement stmt = conn.preparestatement("select * from g12.restaurant join g12.userreview " + "where idrestaurant = ratedrestaurant " + "and idrestaurant =? " + "order by date desc"); stmt.setint(1, restaurantid); ResultSet res = stmt.executequery(); while(res.next()){

22 Review rev = new Review(); rev.setreviewer(res.getstring("rater")); rev.setdate(res.getstring("date")); rev.setcomment(res.getstring("comment")); toprated.add(rev); catch(sqlexception e){ edao = new DAOException("Unable to submit update query for item data.", e); throw edao; finally { // Close the DB connection try { conn.close(); catch (SQLException e) { if (edao == null){ throw new DAOException("Unable to close connection after successful query."); else { throw new DAOException("Unable to close connection after DAPException. SQL message: " + e.tostring(), edao); return toprated; package daos; import java.io.file; import java.sql.connection; import java.sql.preparedstatement; import java.sql.resultset; import java.sql.sqlexception; import java.util.arraylist;

23 import pojo.restaurant; public class SearchDAO { public SearchDAO(){ public ArrayList<Restaurant> advancedsearch(string[] params) throws DAOException { ArrayList<Restaurant> results = new ArrayList<Restaurant>(); Connection conn = ConnectionHandler.getConnection(); DAOException edao = null; try { PreparedStatement stmt = conn.preparestatement("select * FROM g12.restaurant " + "where Name =? or Location =? or Cuisine =? or Type =? or PriceRange =?" + " or delivery =? or seatingoutside =? or reservations =?"); stmt.setstring(1, params[0]); stmt.setstring(2, params[1]); stmt.setstring(3, params[2]); stmt.setstring(4, params[3]); stmt.setstring(5, params[4]); stmt.setstring(6, params[6]); stmt.setstring(7, params[7]); stmt.setstring(8, params[8]); ResultSet res = stmt.executequery(); while(res.next()){ Restaurant rest = new Restaurant(); rest.setrestaurantid(integer.parseint(res.getstring("idrest aurant"))); rest.setname(res.getstring("name")); rest.setlocation(res.getstring("location")); rest.setcuisine(res.getstring("cuisine")); rest.settype(res.getstring("type"));

24 rest.setprice(res.getstring("pricerange")); results.add(rest); String temp = params[5]; while(temp!= null &&!temp.equals("") &&!temp.equalsignorecase("") &&!temp.equals(null)) { stmt = conn.preparestatement("select p.n, avgq, avgserv, avgset, avgovr, p.l, p.c, p.t, p.pr" + " from (select r2.name as n, r2.location as l, r2.cuisine as c, r2.type as t, r2.pricerange as pr, avg(quality) as avgq, avg(service) as avgserv, avg(setting) as avgset, avg(overall) as avgovr"+ " from g12.restaurant as r2 join g12.ratesrestaurant"+ " where r2.idrestaurant = ratedrestaurant group by r2.idrestaurant) as p" + " where avgovr between? and?"); if(integer.parseint(params[5]) == 3)//<3 { stmt.setint(1, 0); stmt.setint(2, 4); if(integer.parseint(params[5]) == 2)//4-6 { stmt.setint(1, 4); stmt.setint(2, 7); if(integer.parseint(params[5]) == 1)//>7 { stmt.setint(1, 7); stmt.setint(2, 10); res = stmt.executequery(); if(results.isempty()) { while(res.next()){ Restaurant rest = new

25 Restaurant(); rest.setname(res.getstring("n")); rest.setlocation(res.getstring("l")); rest.setcuisine(res.getstring("c")); rest.settype(res.getstring("t")); rest.setprice(res.getstring("pr")); rest.setrating(res.getstring("avgovr")); rest.setquality((res.getstring("avgq"))); rest.setservice((res.getstring("avgserv"))); rest.setsetting((res.getstring("avgset"))); results.add(rest); else for(restaurant r : results) { if((r.name).equals(res.getstring("n"))) { r.setrating(res.getstring("avgovr")); r.setquality((res.getstring("avgq"))); r.setservice((res.getstring("avgserv"))); r.setsetting((res.getstring("avgset"))); stmt.close();

26 catch (SQLException e){ edao = new DAOException("Unable to submit query for student data.", e); throw edao; finally{ // Close the DB connection try { conn.close(); catch (SQLException e) { if (edao == null){ throw new DAOException("Unable to close connection after successful query."); else { throw new DAOException("Unable to close connection after DAPException. SQL message: " + e.tostring(), edao); return results; package pojo; import java.sql.date; public class Article { private int articleid; private String title; private Date date; public Article(int articleid, String title, Date date) { super(); this.articleid = articleid; this.title = title; this.date = date;

27 public Article() { super(); public int getarticleid() { return articleid; public void setarticleid(int articleid) { this.articleid = articleid; public String gettitle() { return title; public void settitle(string title) { this.title = title; public Date getdate() { return date; public void setdate(date date) { this.date = date; package pojo; import java.text.dateformat; import java.text.simpledateformat; import java.util.date; public class Chef extends RegisteredUser { private int yoe;

28 private String curriculumvitae; public Chef(String lastname, String firstname, String username, String password, String , String phonenumber, String address, String city, String country) { super(); public Chef(int yoe, String curriculumvitae) { super(); this.yoe = yoe; this.curriculumvitae = curriculumvitae; public int getyoe() { return yoe; public void setyoe(int yoe) { this.yoe = yoe; public String getcurriculumvitae() { return curriculumvitae; public void setcurriculumvitae(string curriculumvitae) { this.curriculumvitae = curriculumvitae;

29 package pojo; import java.sql.date; import java.sql.time; import java.util.arraylist; public class Event { private String time; private String date; private String title; private String description; private String venue; public Event() { super(); public Event(String time, String date, String title, String description, String venue) { super(); this.time = time; this.date = date; this.title = title; this.description = description; this.venue = venue; public String getvenue() { return venue; public void setvenue(string venue) { this.venue = venue; public void seteventid(string date, String time){ this.date = date; this.time = time;

30 public String geteventid(){ return this.date + " " + this.time; public String gettime() { return time; public void settime(string time) { this.time = time; public String getdate() { return date; public void setdate(string date) { this.date = date; public String gettitle() { return title; public void settitle(string title) { this.title = title; public String getdescription() { return description; public void setdescription(string description) { this.description = description; package pojo;

31 import java.sql.date; import java.util.arraylist; public class Recipe { public static int recipeid; private String date; private String title; private String description; public Recipe() { super(); public Recipe(int recipeid, String date, String title, String description) { super(); this.recipeid = recipeid; this.date = date; this.title = title; this.description = description; public int getrecipeid() { return recipeid; public void setrecipeid(int recipeid) { this.recipeid = recipeid; public String getdate() { return date; public void setdate(string date) { this.date = date; public String gettitle() { return title;

32 public void settitle(string title) { this.title = title; public String getdescription() { return description; public void setdescription(string description) { this.description = description; public static ArrayList<Recipe> recipes; static{ recipes = new ArrayList<Recipe>(); recipes.add(new Recipe(recipeID,"15/12/2010","Lechon Asado","descripcion")); recipes.add(new Recipe()); recipes.add(new Recipe()); recipes.add(new Recipe()); recipes.add(new Recipe()); recipes.add(new Recipe()); recipes.add(new Recipe());

33 package pojo; import java.util.hashmap; import pojo.administrator; import pojo.registereduser; import pojo.role; public class RegisteredUser { private int registereduserid; private String ; private String username; private String password; private String name; private String city; private String phonenumber; private String lastname; private String maidenname; private String country; static private Role role; public RegisteredUser(){ super(); public RegisteredUser(String , String username,string password,string name, String lastname, String maidenname, String city, String country, String phonenumber) { super(); this. = ; this.username = username; this.password = password; this.name = name; this.city = city; this.phonenumber = phonenumber; this.lastname = lastname; this.maidenname = maidenname; this.country = country; RegisteredUser.role = role; public Integer getregistereduserid(){ return registereduserid;

34 public void setregistereduserid(int registereduserid){ this.registereduserid = registereduserid; public String get () { return ; public void set (string ) { this. = ; public String getusername() { return username; public void setusername(string username) { this.username = username; public String getpassword() { return password; public void setpassword(string password) { this.password = password; public Role getrole() { return role; public String getname() { return name; public void setname(string name) { this.name = name; public String getlastname(){ return lastname; public void setlastname(string lastname){ this.lastname = lastname; public String getmaidenname(){ return maidenname; public void setmaidenname(string maidenname){ this.maidenname = maidenname;

35 public String getcity() { return city; public void setcity(string city) { this.city = city; public String getcountry(){ return country; public void setcountry(string country){ this.country = country; public String getphonenumber() { return phonenumber; public void setphonenumber(string phonenumber) { this.phonenumber = phonenumber; public static void setrole(role role) { RegisteredUser.role = role; package pojo; public class Restaurant { private int restaurantid; public String name; public String location; public String cuisine; public String type; public String price; public String rating; public String quality; public String service; public String setting; protected String delivery; protected String fax; protected String limitations; protected String days; protected String ;

36 protected String message; protected String subject; protected String username; protected String seating; protected String reservations; protected String website; protected String phone; protected String hours; protected String other; private String address; private String address1; public Restaurant() { super(); public int getrestaurantid() { return restaurantid; public void setrestaurantid(int restaurantid) { this.restaurantid = restaurantid; public String getname() { return name; public void setname(string name) { this.name = name; public String getlocation() { return location; public void setlocation(string location) { this.location = location; public String getcuisine() { return cuisine;

37 public void setcuisine(string cuisine) { this.cuisine = cuisine; public String gettype() { return type; public void settype(string type) { this.type = type; public String getprice() { return price; public void setprice(string price) { this.price = price; public String getrating() { return rating; public void setrating(string rating) { this.rating = rating; public String getquality() { return quality; public void setquality(string quality) { this.quality = quality; public String getservice() { return service; public void setservice(string service) { this.service = service;

38 public String getsetting() { return setting; public void setsetting(string setting) { this.setting = setting; public String getdelivery() { return delivery; public void setdelivery(string delivery) { this.delivery = delivery; public String getseating() { return seating; public void setseating(string seating) { this.seating = seating; public String getreservations() { return reservations; public void setreservations(string reservations) { this.reservations = reservations; public String getwebsite() { return website; public void setwebsite(string website) { this.website = website; public String getfax(){ return fax;

39 public void setfax(string fax){ this.fax = fax; public String getphone() { return phone; public void setphone(string phone) { this.phone = phone; public String gethours() { return hours; public void sethours(string hours) { this.hours = hours; public String getdays(){ return days; public void setdays(string days){ this.days = days; public String getlimitations(){ return limitations; public void setlimitations(string limitations){ this.limitations = limitations; public void setaddress(string address) { this.address = address; public String getaddress() { return address; public void setaddress1(string address1) {

40 this.address1 = address1; public String getaddress1() { return address1; public String getother() { return other; public void setother(string other) { this.other = other; public Restaurant(String name, String location, String cuisine, String type, String price, String delivery, String seating, String reservations, String website, String phone, String hours, String days, String limitations, String fax, String address, String address1, String other) { super(); this.price = price; this.name = name; this.location = location; this.cuisine = cuisine; this.type = type; this.delivery = delivery; this.seating = seating; this.reservations = reservations; this.days = days; this.website = website; this.phone = phone; this.hours = hours; this.address = address; this.setaddress1(address1); this.limitations = limitations; this.fax = fax; this.other = other;

41 package pojo; import java.util.arraylist; public class Review { public static int reviewid; private double servicescore; private double foodqualityscore; private double settingscore; private double totalscore; private String comment; private int restaurantid; private String reviewer; private String date; public String getreviewer() { return reviewer; public void setreviewer(string reviewer) { this.reviewer = reviewer; public Review() { super(); public Review(double servicescore, double foodqualityscore, double settingscore, double totalscore, String comment, String reviewer, int restaurantid) { super(); this.reviewid = reviewid; this.servicescore = servicescore; this.foodqualityscore = foodqualityscore; this.settingscore = settingscore; this.totalscore = totalscore; this.comment = comment; this.reviewer = reviewer; this.restaurantid = restaurantid;

42 public int getreviewid() { return reviewid; public void setreviewid(int reviewid) { this.reviewid = reviewid; public double getservicescore() { return servicescore; public void setservicescore(double servicescore) { this.servicescore = servicescore; public double getfoodqualityscore() { return foodqualityscore; { public void setfoodqualityscore(double foodqualityscore) this.foodqualityscore = foodqualityscore; public double getsettingscore() { return settingscore; public void setsettingscore(double settingscore) { this.settingscore = settingscore; public double gettotalscore() { return totalscore; public void settotalscore(double totalscore) { this.totalscore = totalscore; public String getcomment() {

43 return comment; public void setcomment(string comment) { this.comment = comment; public void setrestaurantid(int restaurantid) { this.restaurantid = restaurantid; public int getrestaurantid() { return restaurantid; public void setdate(string date) { this.date = date; public String getdate() { return this.date; package servlets; import java.io.ioexception; import java.util.arraylist; import javax.servlet.servletexception; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import javax.servlet.http.httpsession; import daos.daoexception; import daos.restaurantdao; import pojo.restaurant; /** * Servlet implementation class AddRestaurant

44 */ public class AddRestaurant extends HttpServlet { private static final long serialversionuid = 1L; /** HttpServlet#HttpServlet() */ public AddRestaurant() { super(); // TODO Auto-generated constructor stub /** HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getsession(); RestaurantDAO restdao = new RestaurantDAO(); String addr = "./RestMenuFormSubmit.jsp"; String name = request.getparameter("restaurantname"); String location = request.getparameter("selectlocation"); String cuisine = request.getparameter("selectcuisine"); String type = request.getparameter("selecttype"); String price = request.getparameter("selectprice"); String address = request.getparameter("restaurantaddress"); String address1 = request.getparameter("restaurantaddress1"); String phone = request.getparameter("phonenumber"); String fax = request.getparameter("faxnumber"); String website = request.getparameter("website"); String hours = request.getparameter("hoursoperation"); String days = request.getparameter("daysoperation"); String seating = request.getparameter("seatingoutside"); String reservations = request.getparameter("reservations");

45 String delivery = request.getparameter("delivery"); String limitations = request.getparameter("deliverylimitations"); String other = request.getparameter("otherinfo"); String username = request.getparameter("username"); String = request.getparameter(" "); String subject = request.getparameter("subject"); String message = request.getparameter("message"); Restaurant rest = new Restaurant(name, location, cuisine, type, price, delivery, seating, reservations, website, phone, hours, days, limitations, fax, address, address1, other); try { restdao.addrestaurant(rest); catch (DAOException e) { e.printstacktrace(); response.sendredirect(addr); /** HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void dopost(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { super.doget(request, response); package servlets; import java.io.file; import java.io.ioexception; import java.util.arraylist; import javax.servlet.servletexception; import javax.servlet.servletrequest;

46 import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import javax.servlet.http.httpsession; import daos.daoexception; import daos.reviewdao; import pojo.registereduser; import pojo.restaurant; import pojo.review; public class AddReview extends HttpServlet { private static final long serialversionuid = 1L; protected void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getsession(); String addr = "Restaurant Review.jsp"; ReviewDAO reviewdao = new ReviewDAO(); String servicescore = request.getparameter("service"); String foodqualityreview = request.getparameter("foodquality"); String settingscore = request.getparameter("setting"); int restaurantid = ((Restaurant)session.getAttribute("displayRest")).getRestaurantID (); int totalscore = (Integer.parseInt(serviceScore)+Integer.parseInt(foodQualityRevie w)+integer.parseint(settingscore))/3; String comment = request.getparameter("txtcomment"); String reviewer = ((RegisteredUser) session.getattribute("logged")).getusername(); Review review = new Review(Integer.parseInt(serviceScore), Integer.parseInt(foodQualityReview), Integer.parseInt(settingScore),totalScore, comment, reviewer, restaurantid);

47 try { reviewdao.addreview(review); catch (DAOException e) { e.printstacktrace(); protected void dopost(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { super.doget(request, response); package servlets; import java.io.ioexception; import javax.servlet.servletexception; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import pojo.administrator; import pojo.chef; import pojo.registereduser; public class CreateUser extends HttpServlet { private static final long serialversionuid = protected void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { String = request.getparameter(" "); String name = request.getparameter("name");

48 String maidenname = request.getparameter("maiden Name"); String city = request.getparameter("city"); String lastname = request.getparameter("last Name"); String username = request.getparameter("username"); String phonenumber = request.getparameter("phone number"); String country = request.getparameter("country"); String zip = request.getparameter("zip"); String password = request.getparameter("password"); String address = request.getparameter("address"); String role = request.getparameter("radiogroup1"); if (role.equals("administrator")) { Administrator admin = new Administrator(lastName, name, username, password, , phonenumber, maidenname, city, country); response.sendredirect("./admin/admin.jsp"); else { Chef chef = new Chef(lastName, name, username, password, , phonenumber, city, maidenname, country); protected void dopost(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { doget(request, response); package servlets; import java.io.ioexception; import java.util.arraylist; import javax.servlet.servletexception; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest;

49 import javax.servlet.http.httpservletresponse; import javax.servlet.http.httpsession; import pojo.event; import pojo.restaurant; import daos.daoexception; import daos.eventdao; import daos.restaurantdao; import daos.searchdao; /** * Servlet implementation class DisplayEvent */ public class DisplayEvent extends HttpServlet { private static final long serialversionuid = 1L; EventDAO eventdao = new EventDAO(); /** HttpServlet#HttpServlet() */ public DisplayEvent() { super(); // TODO Auto-generated constructor stub /** HttpServlet#service(ServletRequest, ServletResponse) */ public void service(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException{ this.init(); HttpSession session = request.getsession(); ArrayList<Event> events = new ArrayList<Event>(); String addr = "./HomePage.jsp"; if(request.getparameter("eid") == null) { try { events = eventdao.queryevents(); catch (DAOException e) { session.setattribute("events", null);

50 if(events.isempty()) session.setattribute("events", null); else session.setattribute("events", events); else response.sendredirect(addr); this.doget(request, response); /** HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getsession(); EventDAO eventdao = new EventDAO(); Event todisplay = new Event(); String addr = "./Event Page.jsp"; String eventid = request.getparameter("eid"); try { todisplay = eventdao.findevent(eventid); catch (DAOException e) { session.setattribute("results", e.getmessage()); session.setattribute("displayevent", todisplay); response.sendredirect(addr); /** HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void dopost(httpservletrequest request,

51 HttpServletResponse response) throws ServletException, IOException { package servlets; import java.io.ioexception; import java.util.arraylist; import javax.servlet.servletexception; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import javax.servlet.http.httpsession; import pojo.event; import pojo.restaurant; import daos.daoexception; import daos.eventdao; import daos.restaurantdao; import daos.searchdao; /** * Servlet implementation class DisplayEvent */ public class DisplayEvent2 extends HttpServlet { private static final long serialversionuid = 1L; EventDAO eventdao = new EventDAO(); /** HttpServlet#HttpServlet() */ public DisplayEvent2() { super(); // TODO Auto-generated constructor stub /**

52 HttpServlet#service(ServletRequest, ServletResponse) */ public void service(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException{ this.init(); HttpSession session = request.getsession(); ArrayList<Event> events = new ArrayList<Event>(); ArrayList<Event> todisplay = new ArrayList<Event>(); //Integer restaurantid = Integer.parseInt(request.getParameter("pid")); String addr = "./Events.jsp"; if(request.getparameter("eid") == null) { try { events = eventdao.queryevents(); todisplay = eventdao.upcomingevents(); catch (DAOException e) { session.setattribute("events", null); session.setattribute("upcomingevents", null); if(events.isempty()){ session.setattribute("events", null); session.setattribute("upcomingevents", null); else{ session.setattribute("events", events); session.setattribute("upcomingevents", todisplay); else response.sendredirect(addr); this.doget(request, response);

53 /** HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getsession(); EventDAO eventdao = new EventDAO(); Event todisplay = new Event(); String addr = "./Event Page.jsp"; String eventid = request.getparameter("eid"); try { todisplay = eventdao.findevent(eventid); catch (DAOException e) { session.setattribute("results", e.getmessage()); session.setattribute("displayevent", todisplay); response.sendredirect(addr); /** HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void dopost(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { package servlets; import java.io.ioexception;

54 import java.util.arraylist; import javax.servlet.servletexception; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import javax.servlet.http.httpsession; import pojo.event; import pojo.restaurant; import daos.daoexception; import daos.eventdao; import daos.restaurantdao; import daos.searchdao; /** * Servlet implementation class DisplayEvent */ public class HomePageServlet extends HttpServlet { private static final long serialversionuid = 1L; EventDAO eventdao = new EventDAO(); RestaurantDAO restdao = new RestaurantDAO(); /** HttpServlet#HttpServlet() */ public HomePageServlet() { super(); // TODO Auto-generated constructor stub /** HttpServlet#service(ServletRequest, ServletResponse) */ public void service(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException{ this.init(); HttpSession session = request.getsession(); ArrayList<Event> events = new ArrayList<Event>(); ArrayList<Restaurant> todisplay = new ArrayList<Restaurant>(); String addr = "./HomePage.jsp";

55 if(request.getparameter("eid") == null) { try { events = eventdao.queryevents(); todisplay = restdao.topratedrestaurant(); catch (DAOException e) { session.setattribute("events", null); session.setattribute("toprest", null); if(events.isempty()){ session.setattribute("events", null); session.setattribute("toprest", null); else{ session.setattribute("events", events); session.setattribute("toprest", todisplay); else response.sendredirect(addr); this.doget(request, response); /** HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getsession(); EventDAO eventdao = new EventDAO(); Event todisplay = new Event(); String addr = "./Event Page.jsp"; String eventid = request.getparameter("eid"); try { todisplay = eventdao.findevent(eventid); catch (DAOException e) { session.setattribute("results", e.getmessage());

56 session.setattribute("displayevent", todisplay); response.sendredirect(addr); /** HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void dopost(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { package servlets; import java.io.ioexception; import javax.servlet.servlet; import javax.servlet.servletexception; import javax.servlet.http.cookie; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import javax.servlet.http.httpsession; import daos.daoexception; import daos.registereduserdao; import util.message; import public class LoginServlet extends HttpServlet implements Servlet { protected void doget(httpservletrequest request, HttpServletResponse response) throws

57 ServletException, IOException { HttpSession session = request.getsession(); RegisteredUserDAO userdao = new RegisteredUserDAO(); Message message = new Message(); RegisteredUser user = new RegisteredUser(); user.setusername(request.getparameter("username")); user.setpassword(request.getparameter("password")); if (user.getusername() == null user.getusername() == "") { message.setmessage("please enter Username & Password"); session.setattribute("message", message); response.sendredirect("./login.jsp"); else { session.setattribute("message", null); try { user = userdao.finduser(user.getusername()); if (user!= null) { "))) user); if(user.getpassword().equals(request.getparameter("password Cookie("login", "1")); { session.setattribute("logged", response.addcookie(new if(session.getattribute("previouspage")!= null) { if ((session.getattribute("previouspage")).equals("review")) { response.sendredirect("./addreview.jsp"); else {

58 response.sendredirect("./homepageservlet"); else { response.sendredirect("./homepageservlet"); else { message.setmessage("incorrect password."); session.setattribute("message", message); response.sendredirect("./login.jsp"); username."); message); else { message.setmessage("inexistent session.setattribute("message", response.sendredirect("./login.jsp"); catch (DAOException e) { // TODO Auto-generated catch block e.printstacktrace(); protected void dopost(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { super.doget(request, response);

59 package servlets; import java.io.ioexception; import java.util.arraylist; import javax.servlet.servletexception; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import javax.servlet.http.httpsession; import daos.*; import pojo.registereduser; import pojo.restaurant; /** * Servlet implementation class AddRestaurant */ public class RegisterUserServlet extends HttpServlet { private static final long serialversionuid = 1L; /** HttpServlet#HttpServlet() */ public RegisterUserServlet() { super(); // TODO Auto-generated constructor stub /** HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getsession(); RegisteredUserDAO userdao = new RegisteredUserDAO(); String addr = "./index.jsp"; String = request.getparameter(" ");

Author - Ashfaque Ahmed

Author - Ashfaque Ahmed Complimentary material for the book Software Engineering in the Agile World (ISBN: 978-1983801570) published by Create Space Independent Publishing Platform, USA Author - Ashfaque Ahmed Technical support

More information

Complimentary material for the book Software Engineering in the Agile World

Complimentary material for the book Software Engineering in the Agile World Complimentary material for the book Software Engineering in the Agile World (ISBN: 978-93-5300-898-7) published by Amazon, USA (ISBN: 978-1976901751) and Flushing Meadows Publishers, India (ISBN: 978-93-5300-898-7)

More information

CSE 530A. DAOs and MVC. Washington University Fall 2012

CSE 530A. DAOs and MVC. Washington University Fall 2012 CSE 530A DAOs and MVC Washington University Fall 2012 Model Object Example public class User { private Long id; private String username; private String password; public Long getid() { return id; public

More information

CreateServlet.java

CreateServlet.java Classes in OBAAS 1.2: -------------------- The package name is pack_bank. Create this package in java source of your project. Create classes as per the class names provided here. You can then copy the

More information

Université Antonine - Baabda

Université Antonine - Baabda Université Antonine - Baabda Faculté d ingénieurs en Informatique, Multimédia, Systèmes, Réseaux et Télécommunications Applications mobiles (Pocket PC, etc ) Project: Manipulate School Database Préparé

More information

Servlet 5.1 JDBC 5.2 JDBC

Servlet 5.1 JDBC 5.2 JDBC 5 Servlet Java 5.1 JDBC JDBC Java DataBase Connectivity Java API JDBC Java Oracle, PostgreSQL, MySQL Java JDBC Servlet OpenOffice.org ver. 2.0 HSQLDB HSQLDB 100% Java HSQLDB SQL 5.2 JDBC Java 1. JDBC 2.

More information

Develop an Enterprise Java Bean for Banking Operations

Develop an Enterprise Java Bean for Banking Operations Develop an Enterprise Java Bean for Banking Operations Aim: Develop a Banking application using EJB3.0 Software and Resources: Software or Resource Version Required NetBeans IDE 6.7, Java version Java

More information

CREATE A SERVLET PROGRAM TO DISPLAY THE STUDENTS MARKS. To create a servlet program to display the students marks

CREATE A SERVLET PROGRAM TO DISPLAY THE STUDENTS MARKS. To create a servlet program to display the students marks CREATE A SERVLET PROGRAM TO DISPLAY THE STUDENTS MARKS DATE: 30.9.11 Aim: To create a servlet program to display the students marks Hardware requirements: Intel Core 2 Quad 2GB RAM Software requirements:

More information

Advanced Internet Technology Lab # 4 Servlets

Advanced Internet Technology Lab # 4 Servlets Faculty of Engineering Computer Engineering Department Islamic University of Gaza 2011 Advanced Internet Technology Lab # 4 Servlets Eng. Doaa Abu Jabal Advanced Internet Technology Lab # 4 Servlets Objective:

More information

WEB SERVICES EXAMPLE 2

WEB SERVICES EXAMPLE 2 INTERNATIONAL UNIVERSITY HCMC PROGRAMMING METHODOLOGY NONG LAM UNIVERSITY Instructor: Dr. Le Thanh Sach FACULTY OF IT WEBSITE SPECIAL SUBJECT Student-id: Instructor: LeMITM04015 Nhat Tung Course: IT.503

More information

SQream Connector JDBC SQream Technologies Version 2.9.3

SQream Connector JDBC SQream Technologies Version 2.9.3 SQream Connector JDBC 2.9.3 SQream Technologies 2019-03-27 Version 2.9.3 Table of Contents The SQream JDBC Connector - Overview...................................................... 1 1. API Reference............................................................................

More information

J2ME With Database Connection Program

J2ME With Database Connection Program J2ME With Database Connection Program Midlet Code: /* * To change this template, choose Tools Templates * and open the template in the editor. package hello; import java.io.*; import java.util.*; import

More information

Principles and Techniques of DBMS 6 JSP & Servlet

Principles and Techniques of DBMS 6 JSP & Servlet Principles and Techniques of DBMS 6 JSP & Servlet Haopeng Chen REliable, INtelligent and Scalable Systems Group (REINS) Shanghai Jiao Tong University Shanghai, China http://reins.se.sjtu.edu.cn/~chenhp

More information

Departamento de Lenguajes y Sistemas Informáticos

Departamento de Lenguajes y Sistemas Informáticos Departamento de Lenguajes y Sistemas Informáticos ! " # $% &'' () * +, ! -. /,#0 &. +, +*,1 $23.*4.5*46.-.2) 7.,8 +*,1 $ 6 +*,1) $23.*4.5 7.-.2) 9 :$java.sql.*),,1 $ ;0,9,1

More information

To create a view for students, staffs and courses in your departments using servlet/jsp.

To create a view for students, staffs and courses in your departments using servlet/jsp. Aim To create a view for students, staffs and courses in your departments using servlet/jsp. Software Requirements: Java IDE Database Server JDK1.6 Netbean 6.9/Eclipse MySQL Tomcat/Glassfish Login Form

More information

ServletConfig Interface

ServletConfig Interface ServletConfig Interface Author : Rajat Categories : Advance Java An object of ServletConfig is created by the web container for each servlet. This object can be used to get configuration information from

More information

A.1 JSP A.2 JSP JSP JSP. MyDate.jsp page contenttype="text/html; charset=windows-31j" import="java.util.calendar" %>

A.1 JSP A.2 JSP JSP JSP. MyDate.jsp page contenttype=text/html; charset=windows-31j import=java.util.calendar %> A JSP A.1 JSP Servlet Java HTML JSP HTML Java ( HTML JSP ) JSP Servlet Servlet HTML JSP MyDate.jsp

More information

C:/Users/zzaier/Documents/NetBeansProjects/WebApplication4/src/java/mainpackage/MainClass.java

C:/Users/zzaier/Documents/NetBeansProjects/WebApplication4/src/java/mainpackage/MainClass.java package mainpackage; import java.sql.connection; import java.sql.drivermanager; import java.sql.resultset; import java.sql.sqlexception; import java.sql.statement; import javax.ws.rs.core.context; import

More information

DEZVOLTAREA APLICATIILOR WEB CURS 7. Lect. Univ. Dr. Mihai Stancu

DEZVOLTAREA APLICATIILOR WEB CURS 7. Lect. Univ. Dr. Mihai Stancu DEZVOLTAREA APLICATIILOR WEB CURS 7 Lect. Univ. Dr. Mihai Stancu S u p o r t d e c u r s suport (Beginning JSP, JSF and Tomcat) Capitolul 3 JSP Application Architectures DEZVOLTAREA APLICATIILOR WEB CURS

More information

Kamnoetvidya Science Academy. Object Oriented Programming using Java. Ferdin Joe John Joseph. Java Session

Kamnoetvidya Science Academy. Object Oriented Programming using Java. Ferdin Joe John Joseph. Java Session Kamnoetvidya Science Academy Object Oriented Programming using Java Ferdin Joe John Joseph Java Session Create the files as required in the below code and try using sessions in java servlets web.xml

More information

Injection Of Datasource

Injection Of Datasource Injection Of Datasource Example injection-of-datasource can be browsed at https://github.com/apache/tomee/tree/master/examples/injection-of-datasource Help us document this example! Click the blue pencil

More information

S.No File Name Path Description 1 DataSourceElement.java Jmeter/src/protocol/jdbc/org/a pache/jmeter/protocol/jdbc/ autocsv_jdbcconfig

S.No File Name Path Description 1 DataSourceElement.java Jmeter/src/protocol/jdbc/org/a pache/jmeter/protocol/jdbc/ autocsv_jdbcconfig AutoCSV_jdbc config For testing an application which has a form or request that takes multiple data entries from a large number of users and the data entries are required to be unique for different users,it

More information

Databases 2012 Embedded SQL

Databases 2012 Embedded SQL Databases 2012 Christian S. Jensen Computer Science, Aarhus University SQL is rarely written as ad-hoc queries using the generic SQL interface The typical scenario: client server database SQL is embedded

More information

Practice for JEE5. Using stateless session EJB 3.0 as a business layer, ADF data Model as a model layer and ADF faces as a view layer. Version 1.

Practice for JEE5. Using stateless session EJB 3.0 as a business layer, ADF data Model as a model layer and ADF faces as a view layer. Version 1. Practice for JEE5 Using stateless session EJB 3.0 as a business layer, ADF data Model as a model layer and ADF faces as a view layer. Version 1.1 Modified by: Dr. Ahmad Taufik Jamil BSc (Med), MD, MPH,

More information

CIS 3952 [Part 2] Java Servlets and JSP tutorial

CIS 3952 [Part 2] Java Servlets and JSP tutorial Java Servlets Example 1 (Plain Servlet) SERVLET CODE import java.io.ioexception; import java.io.printwriter; import javax.servlet.servletexception; import javax.servlet.annotation.webservlet; import javax.servlet.http.httpservlet;

More information

= "categories") 1 public class Category implements java.io.serializable { 2 private static final long serialversionuid = 1L;

= categories) 1 public class Category implements java.io.serializable { 2 private static final long serialversionuid = 1L; @Entity @Table(name = "categories") 1 public class Category implements java.io.serializable { 2 private static final long serialversionuid = 1L; @Id @GeneratedValue 3 private Long id; 4 private String

More information

Chapter 2 How to structure a web application with the MVC pattern

Chapter 2 How to structure a web application with the MVC pattern Chapter 2 How to structure a web application with the MVC pattern Murach's Java Servlets/JSP (3rd Ed.), C2 2014, Mike Murach & Associates, Inc. Slide 1 Objectives Knowledge 1. Describe the Model 1 pattern.

More information

Model Driven Architecture with Java

Model Driven Architecture with Java Model Driven Architecture with Java Gregory Cranz Solutions Architect Arrow Electronics, Inc. V20061005.1351 Page Number.1 Who am I? Solutions Architect Software Developer Java Early Adopter Page Number.2

More information

CSC System Development with Java. Database Connection. Department of Statistics and Computer Science. Budditha Hettige

CSC System Development with Java. Database Connection. Department of Statistics and Computer Science. Budditha Hettige CSC 308 2.0 System Development with Java Database Connection Budditha Hettige Department of Statistics and Computer Science Budditha Hettige 1 From database to Java There are many brands of database: Microsoft

More information

access to a JCA connection in WebSphere Application Server

access to a JCA connection in WebSphere Application Server Understanding connection transitions: Avoiding multithreaded access to a JCA connection in WebSphere Application Server Anoop Ramachandra (anramach@in.ibm.com) Senior Staff Software Engineer IBM 09 May

More information

XSTREAM - QUICK GUIDE XSTREAM - OVERVIEW

XSTREAM - QUICK GUIDE XSTREAM - OVERVIEW XSTREAM - QUICK GUIDE http://www.tutorialspoint.com/xstream/xstream_quick_guide.htm Copyright tutorialspoint.com XSTREAM - OVERVIEW XStream is a simple Java-based library to serialize Java objects to XML

More information

Servlets by Example. Joe Howse 7 June 2011

Servlets by Example. Joe Howse 7 June 2011 Servlets by Example Joe Howse 7 June 2011 What is a servlet? A servlet is a Java application that receives HTTP requests as input and generates HTTP responses as output. As the name implies, it runs on

More information

1. PhP Project. Create a new PhP Project as shown below and click next

1. PhP Project. Create a new PhP Project as shown below and click next 1. PhP Project Create a new PhP Project as shown below and click next 1 Choose Local Web Site (Apache 24 needs to be installed) Project URL is http://localhost/projectname Then, click next We do not use

More information

An implementation of Tree Panel component in EXT JS 4.0

An implementation of Tree Panel component in EXT JS 4.0 An implementation of Tree Panel component in EXT JS 4.0 By Hamid M. Porasl This implementation contains an HTML file that t is used to invoke used EXT JS java script files and our implemented java Script

More information

Trusted Source SSO. Document version 2.3 Last updated: 30/10/2017.

Trusted Source SSO. Document version 2.3 Last updated: 30/10/2017. Trusted Source SSO Document version 2.3 Last updated: 30/10/2017 www.iamcloud.com TABLE OF CONTENTS 1 INTRODUCTION... 1 2 PREREQUISITES... 2 2.1 Agent... 2 2.2 SPS Client... Error! Bookmark not defined.

More information

Integrate JPEGCAM with WaveMaker

Integrate JPEGCAM with WaveMaker Integrate JPEGCAM with WaveMaker 1.Start a new project on wavemaker or use your current project 2.On Main page or desired page add a panel widget and put name panelholder 3.Create a wm.variable called

More information

Accessing EJB in Web applications

Accessing EJB in Web applications Accessing EJB in Web applications 1. 2. 3. 4. Developing Web applications Accessing JDBC in Web applications To run this tutorial, as a minimum you will be required to have installed the following prerequisite

More information

Assignment -3 Source Code. Student.java

Assignment -3 Source Code. Student.java import java.io.serializable; Assignment -3 Source Code Student.java public class Student implements Serializable{ public int rollno; public String name; public double marks; public Student(int rollno,

More information

Practice for JEE5 for JDeveloper 11g

Practice for JEE5 for JDeveloper 11g Practice for JEE5 for JDeveloper 11g Using stateless session EJB 3.0 as a business layer, ADF data Model as a model layer and ADF Faces Rich Client as a view layer. Modified by: Dr. Ahmad Taufik Jamil

More information

Scheme G Sample Question Paper Unit Test 2

Scheme G Sample Question Paper Unit Test 2 Scheme G Sample Question Paper Unit Test 2 Course Name: Computer Engineering Group Course Code: CO/CD/CM/CW/IF Semester: Sixth Subject Title: Advanced Java Programming Marks: 25 Marks 17625 ---------------------------------------------------------------------------------------------------------------------------

More information

Java Database Connectivity

Java Database Connectivity Java Database Connectivity INTRODUCTION Dr. Syed Imtiyaz Hassan Assistant Professor, Deptt. of CSE, Jamia Hamdard (Deemed to be University), New Delhi, India. s.imtiyaz@jamiahamdard.ac.in Agenda Introduction

More information

EJB - ACCESS DATABASE

EJB - ACCESS DATABASE EJB - ACCESS DATABASE http://www.tutorialspoint.com/ejb/ejb_access_database.htm Copyright tutorialspoint.com EJB 3.0, persistence mechanism is used to access the database in which container manages the

More information

Cyrus Shahabi Computer Science Department University of Southern California C. Shahabi

Cyrus Shahabi Computer Science Department University of Southern California C. Shahabi Application Programming for Relational Databases Cyrus Shahabi Computer Science Department University of Southern California shahabi@usc.edu 1 Overview JDBC Package Connecting to databases with JDBC Executing

More information

Application Programming for Relational Databases

Application Programming for Relational Databases Application Programming for Relational Databases Cyrus Shahabi Computer Science Department University of Southern California shahabi@usc.edu 1 Overview JDBC Package Connecting to databases with JDBC Executing

More information

DATABASE DESIGN I - 1DL300

DATABASE DESIGN I - 1DL300 DATABASE DESIGN I - 1DL300 Fall 2010 An introductory course on database systems http://www.it.uu.se/edu/course/homepage/dbastekn/ht10/ Manivasakan Sabesan Uppsala Database Laboratory Department of Information

More information

Quiz System Report. Independent Study. Back-end 2 Servlet 8 Front-end 9 Relationship among back-end, servlet and front-end 9

Quiz System Report. Independent Study. Back-end 2 Servlet 8 Front-end 9 Relationship among back-end, servlet and front-end 9 Quiz System Report Independent Study Qi Chen - April 20, 2016 Introduction 2 The design of this system 2 Back-end 2 Servlet 8 Front-end 9 Relationship among back-end, servlet and front-end 9 Some techniques

More information

Unit-4: Servlet Sessions:

Unit-4: Servlet Sessions: 4.1 What Is Session Tracking? Unit-4: Servlet Sessions: Session tracking is the capability of a server to maintain the current state of a single client s sequential requests. Session simply means a particular

More information

JDBC [Java DataBase Connectivity]

JDBC [Java DataBase Connectivity] JDBC [Java DataBase Connectivity] Introduction Almost all the web applications need to work with the data stored in the databases. JDBC is Java specification that allows the Java programs to access the

More information

[I] SLT Operations & Maintenance (2009), OSP Maintenance Report, Annual Maintenance Report of Sri Lanka Telecom PLC, 4(3), pp 43-51

[I] SLT Operations & Maintenance (2009), OSP Maintenance Report, Annual Maintenance Report of Sri Lanka Telecom PLC, 4(3), pp 43-51 Reference [I] SLT Operations & Maintenance (2009), OSP Maintenance Report, Annual Maintenance Report of Sri Lanka Telecom PLC, 4(3), pp 43-51 [2] Digi International Inc. (2008), TCP/IP Road Map, A product

More information

Enterprise JavaBeans. Layer:08. Persistence

Enterprise JavaBeans. Layer:08. Persistence Enterprise JavaBeans Layer:08 Persistence Agenda Discuss "finder" methods. Describe DataSource resources. Describe bean-managed persistence. Describe container-managed persistence. Last Revised: 11/1/2001

More information

Topic 12: Database Programming using JDBC. Database & DBMS SQL JDBC

Topic 12: Database Programming using JDBC. Database & DBMS SQL JDBC Topic 12: Database Programming using JDBC Database & DBMS SQL JDBC Database A database is an integrated collection of logically related records or files consolidated into a common pool that provides data

More information

J2EE Web Application Development

J2EE Web Application Development Thinking Machines J2EE Application Programming Page 1 J2EE Web Application Development This is the kind of work that most of you will get, when it comes to Indian Service Industry I will try to take you

More information

Designing a Persistence Framework

Designing a Persistence Framework Designing a Persistence Framework Working directly with code that uses JDBC is low-level data access; As application developers, one is more interested in the business problem that requires this data access.

More information

JDBC Guide. RDM Server 8.2

JDBC Guide. RDM Server 8.2 RDM Server 8.2 JDBC Guide 1 Trademarks Raima Database Manager ("RDM"), RDM Embedded, RDM Server, RDM Mobile, XML, db_query, db_revise and Velocis are trademarks of Birdstep Technology and may be registered

More information

PARTIAL Final Exam Reference Packet

PARTIAL Final Exam Reference Packet PARTIAL Final Exam Reference Packet (Note that some items here may be more pertinent than others; you'll need to be discerning.) Example 1 - St10CommonImportTop.jsp (with comments removed)

More information

Communication Software Exam 5º Ingeniero de Telecomunicación January 26th Name:

Communication Software Exam 5º Ingeniero de Telecomunicación January 26th Name: Duration: Marks: 2.5 hours (+ half an hour for those students sitting part III) 8 points (+ 1 point for part III, for those students sitting this part) Part II: problems Duration: 2 hours Marks: 4 points

More information

JSP. Common patterns

JSP. Common patterns JSP Common patterns Common JSP patterns Page-centric (client-server) CLIENT JSP or Servlet CLIENT Enterprise JavaBeans SERVER DB Common JSP patterns Page-centric 1 (client-server) Page View request response

More information

Programming a Bank Database. We ll store the information in two tables: INTEGER DECIMAL(10, 2)

Programming a Bank Database. We ll store the information in two tables: INTEGER DECIMAL(10, 2) WE1 W o r k e d E x a m p l e 2 2.1 Programming a Bank Database In this Worked Example, we will develop a complete database program. We will reimplement the ATM simulation of Chapter 12, storing the customer

More information

Backend. (Very) Simple server examples

Backend. (Very) Simple server examples Backend (Very) Simple server examples Web server example Browser HTML form HTTP/GET Webserver / Servlet JDBC DB Student example sqlite>.schema CREATE TABLE students(id integer primary key asc,name varchar(30));

More information

Tutorial: Using Java/JSP to Write a Web API

Tutorial: Using Java/JSP to Write a Web API Tutorial: Using Java/JSP to Write a Web API Contents 1. Overview... 1 2. Download and Install the Sample Code... 2 3. Study Code From the First JSP Page (where most of the code is in the JSP Page)... 3

More information

JAVA SERVLET. Server-side Programming PROGRAMMING

JAVA SERVLET. Server-side Programming PROGRAMMING JAVA SERVLET Server-side Programming PROGRAMMING 1 AGENDA Passing Parameters Session Management Cookie Hidden Form URL Rewriting HttpSession 2 HTML FORMS Form data consists of name, value pairs Values

More information

JAVA SERVLET. Server-side Programming ADVANCED FEATURES

JAVA SERVLET. Server-side Programming ADVANCED FEATURES JAVA SERVLET Server-side Programming ADVANCED FEATURES 1 AGENDA RequestDispacher SendRedirect ServletConfig ServletContext ServletFilter SingleThreadedModel Events and Listeners Servlets & Database 2 REQUESTDISPATCHER

More information

MYBATIS - ANNOTATIONS

MYBATIS - ANNOTATIONS MYBATIS - ANNOTATIONS http://www.tutorialspoint.com/mybatis/mybatis_annotations.htm Copyright tutorialspoint.com In the previous chapters, we have seen how to perform curd operations using MyBatis. There

More information

Working with Databases and Java

Working with Databases and Java Working with Databases and Java Pedro Contreras Department of Computer Science Royal Holloway, University of London January 30, 2008 Outline Introduction to relational databases Introduction to Structured

More information

BUSINESS INTELLIGENCE LABORATORY. Data Access: Relational Data Bases. Business Informatics Degree

BUSINESS INTELLIGENCE LABORATORY. Data Access: Relational Data Bases. Business Informatics Degree BUSINESS INTELLIGENCE LABORATORY Data Access: Relational Data Bases Business Informatics Degree RDBMS data access 2 Protocols and API ODBC, OLE DB, ADO, ADO.NET, JDBC JDBC Programming Java classes java.sql

More information

Playlist tutorial. Updated: :00

Playlist tutorial. Updated: :00 Playlist tutorial Updated: 2018-04-23-07:00 2018 DataStax, Inc. All rights reserved. DataStax is a registered trademark of DataStax, Inc. and its subsidiaries in the United States and/or other countries.

More information

COP4540 TUTORIAL PROFESSOR: DR SHU-CHING CHEN TA: H S IN-YU HA

COP4540 TUTORIAL PROFESSOR: DR SHU-CHING CHEN TA: H S IN-YU HA COP4540 TUTORIAL PROFESSOR: DR SHU-CHING CHEN TA: H S IN-YU HA OUTLINE Postgresql installation Introduction of JDBC Stored Procedure POSTGRES INSTALLATION (1) Extract the source file Start the configuration

More information

Java Database Connectivity (JDBC) 25.1 What is JDBC?

Java Database Connectivity (JDBC) 25.1 What is JDBC? PART 25 Java Database Connectivity (JDBC) 25.1 What is JDBC? JDBC stands for Java Database Connectivity, which is a standard Java API for database-independent connectivity between the Java programming

More information

JDBC 3.0. Java Database Connectivity. 1 Java

JDBC 3.0. Java Database Connectivity. 1 Java JDBC 3.0 Database Connectivity 1 Contents 1 JDBC API 2 JDBC Architecture 3 Steps to code 4 Code 5 How to configure the DSN for ODBC Driver for MS-Access 6 Driver Types 7 JDBC-ODBC Bridge 8 Disadvantages

More information

How to program applications. CS 2550 / Spring 2006 Principles of Database Systems. SQL is not enough. Roadmap

How to program applications. CS 2550 / Spring 2006 Principles of Database Systems. SQL is not enough. Roadmap How to program applications CS 2550 / Spring 2006 Principles of Database Systems 05 SQL Programming Using existing languages: Embed SQL into Host language ESQL, SQLJ Use a library of functions Design a

More information

Database Applications (15-415)

Database Applications (15-415) Database Applications (15-415) SQL-Part III & Storing Data: Disks and Files- Part I Lecture 8, February 5, 2014 Mohammad Hammoud Today Last Session: Standard Query Language (SQL)- Part II Today s Session:

More information

DB I. 1 Dr. Ahmed ElShafee, Java course

DB I. 1 Dr. Ahmed ElShafee, Java course Lecture (15) DB I Dr. Ahmed ElShafee 1 Dr. Ahmed ElShafee, Java course Agenda 2 Dr. Ahmed ElShafee, Java course Introduction Java uses something called JDBC (Java Database Connectivity) to connect to databases.

More information

JdbcResultSet.java. import java.sql.*;

JdbcResultSet.java. import java.sql.*; 1)Write a program to display the current contents of the tables in the database where table name is Registration and attributes are id,firstname,lastname,age. JdbcResultSet.java import java.sql.*; public

More information

Oracle Database 2 Day + Java Developer's Guide. 12c Release 2 (12.2)

Oracle Database 2 Day + Java Developer's Guide. 12c Release 2 (12.2) Oracle Database 2 Day + Java Developer's Guide 12c Release 2 (12.2) E85808-01 May 2017 Oracle Database 2 Day + Java Developer's Guide, 12c Release 2 (12.2) E85808-01 Copyright 2007, 2017, Oracle and/or

More information

SWE642 Oct. 22, 2003

SWE642 Oct. 22, 2003 import java.sql.*; import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.arraylist; DataServlet.java /** * First servlet in a two servlet application. It is responsible

More information

Demonstration of Servlet, JSP with Tomcat, JavaDB in NetBeans

Demonstration of Servlet, JSP with Tomcat, JavaDB in NetBeans Demonstration of Servlet, JSP with Tomcat, JavaDB in NetBeans Installation pre-requisites: NetBeans 7.01 or above is installed; Tomcat 7.0.14.0 or above is installed properly with NetBeans; (see step 7

More information

COMP 430 Intro. to Database Systems. SQL from application code

COMP 430 Intro. to Database Systems. SQL from application code COMP 430 Intro. to Database Systems SQL from application code Some issues How to connect to database Where, what type, user credentials, How to send SQL commands How to get communicate data to/from DB

More information

Accessing databases in Java using JDBC

Accessing databases in Java using JDBC Accessing databases in Java using JDBC Introduction JDBC is an API for Java that allows working with relational databases. JDBC offers the possibility to use SQL statements for DDL and DML statements.

More information

CSE 135. Three-Tier Architecture. Applications Utilizing Databases. Browser. App. Server. Database. Server

CSE 135. Three-Tier Architecture. Applications Utilizing Databases. Browser. App. Server. Database. Server CSE 135 Applications Utilizing Databases Three-Tier Architecture Located @ Any PC HTTP Requests Browser HTML Located @ Server 2 App Server JDBC Requests JSPs Tuples Located @ Server 1 Database Server 2

More information

SQLJ: Java and Relational Databases

SQLJ: Java and Relational Databases SQLJ: Java and Relational Databases Phil Shaw, Sybase Inc. Brian Becker, Oracle Corp. Johannes Klein, Tandem/Compaq Mark Hapner, JavaSoft Gray Clossman, Oracle Corp. Richard Pledereder, Sybase Inc. Agenda

More information

Servlet. 1.1 Web. 1.2 Servlet. HTML CGI Common Gateway Interface Web CGI CGI. Java Applet JavaScript Web. Java CGI Servlet. Java. Apache Tomcat Jetty

Servlet. 1.1 Web. 1.2 Servlet. HTML CGI Common Gateway Interface Web CGI CGI. Java Applet JavaScript Web. Java CGI Servlet. Java. Apache Tomcat Jetty 1 Servlet 1.1 Web Web WWW HTML CGI Common Gateway Interface Web HTML Web Web CGI CGI CGI Perl, PHP C Java Applet JavaScript Web CGI HTML 1.2 Servlet Java Servlet Servlet CGI Web CGI 1 Java Java JVM Java

More information

Chettinad College of Engineering and Technology CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE AND TECHNOLOGY

Chettinad College of Engineering and Technology CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE AND TECHNOLOGY CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE AND TECHNOLOGY UNIT IV SERVLETS 1. What is Servlets? a. Servlets are server side components that provide a powerful mechanism

More information

CSC309: Introduction to Web Programming. Lecture 10

CSC309: Introduction to Web Programming. Lecture 10 CSC309: Introduction to Web Programming Lecture 10 Wael Aboulsaadat WebServer - WebApp Communication 2. Servlets Web Browser Get servlet/serv1? key1=val1&key2=val2 Web Server Servlet Engine WebApp1 serv1

More information

Servlets. An extension of a web server runs inside a servlet container

Servlets. An extension of a web server runs inside a servlet container Servlets What is a servlet? An extension of a web server runs inside a servlet container A Java class derived from the HttpServlet class A controller in webapplications captures requests can forward requests

More information

WebSphere Connection Pooling. by Deb Erickson Shawn Lauzon Melissa Modjeski

WebSphere Connection Pooling. by Deb Erickson Shawn Lauzon Melissa Modjeski WebSphere Connection Pooling by Deb Erickson Shawn Lauzon Melissa Modjeski Note: Before using this information and the product it supports, read the information in "Notices" on page 78. First Edition (August

More information

OpenClinica: Towards Database Abstraction, Part 1

OpenClinica: Towards Database Abstraction, Part 1 OpenClinica: Towards Database Abstraction, Part 1 Author: Tom Hickerson, Akaza Research Date Created: 8/26/2004 4:17 PM Date Updated: 6/10/2005 3:22 PM, Document Version: v0.3 Document Summary This document

More information

Introduction to Databases

Introduction to Databases JAVA JDBC Introduction to Databases Assuming you drove the same number of miles per month, gas is getting pricey - maybe it is time to get a Prius. You are eating out more month to month (or the price

More information

WEEK 13 EXAMPLES MONDAY SECTION 2. Author class. public class Author { private static int ID=0; private String AuthorName;

WEEK 13 EXAMPLES MONDAY SECTION 2. Author class. public class Author { private static int ID=0; private String AuthorName; WEEK 13 EXAMPLES MONDAY SECTION 2 Author class public class Author { private static int ID=0; private String AuthorName; private String DOB; public Author() { AuthorName = ""; DOB = ""; public Author(String

More information

Java and XML. XML documents consist of Elements. Each element will contains other elements and will have Attributes. For example:

Java and XML. XML documents consist of Elements. Each element will contains other elements and will have Attributes. For example: Java and XML XML Documents An XML document is a way to represent structured information in a neutral format. The purpose of XML documents is to provide a way to represent data in a vendor and software

More information

Oracle Exam 1z0-809 Java SE 8 Programmer II Version: 6.0 [ Total Questions: 128 ]

Oracle Exam 1z0-809 Java SE 8 Programmer II Version: 6.0 [ Total Questions: 128 ] s@lm@n Oracle Exam 1z0-809 Java SE 8 Programmer II Version: 6.0 [ Total Questions: 128 ] Oracle 1z0-809 : Practice Test Question No : 1 Given: public final class IceCream { public void prepare() { public

More information

a. Jdbc:ids://localhost:12/conn?dsn=dbsysdsn 21. What is the Type IV Driver URL? a. 22.

a. Jdbc:ids://localhost:12/conn?dsn=dbsysdsn 21. What is the Type IV Driver URL? a. 22. Answers 1. What is the super interface to all the JDBC Drivers, specify their fully qualified name? a. Java.sql.Driver i. JDBC-ODBC Driver ii. Java-Native API Driver iii. All Java Net Driver iv. Java Native

More information

INTERNET PROGRAMMING TEST-3 SCHEME OF EVALUATION 1.A 3 LIFE CYCLE METHODS - 3M 1.B HTML FORM CREATION - 2 M

INTERNET PROGRAMMING TEST-3 SCHEME OF EVALUATION 1.A 3 LIFE CYCLE METHODS - 3M 1.B HTML FORM CREATION - 2 M INTERNET PROGRAMMING TEST-3 SCHEME OF EVALUATION 1.A 3 LIFE CYCLE METHODS - 3M EXPLANATION - 1.B HTML FORM CREATION - 2 M SERVLET CODE IN POST METHOD IMPORT STATEMENTS - CLASS NAME AND METHOD (POST) -

More information

Tutorial covering Java EE: JSP 2.2 and Servlets 3.0 with OpenSource Resin Servlet Container: Part 2 Model 2 CRUD

Tutorial covering Java EE: JSP 2.2 and Servlets 3.0 with OpenSource Resin Servlet Container: Part 2 Model 2 CRUD BILLDIGMAN HOM E REFCARDZ M ICROZONES ZONES LIBRARY SNIPPET S T UT ORIALS Search JAVALOBBY Join thought leaders, community members and developers at GraphConnect 2012! Article Tutorial covering Java EE:

More information

Oracle Database 2 Day + Java Developer's Guide. Release 18c

Oracle Database 2 Day + Java Developer's Guide. Release 18c Oracle Database 2 Day + Java Developer's Guide Release 18c E83919-02 May 2018 Oracle Database 2 Day + Java Developer's Guide, Release 18c E83919-02 Copyright 2007, 2018, Oracle and/or its affiliates. All

More information

INF 102 CONCEPTS OF PROG. LANGS ADVERSITY. Instructors: James Jones Copyright Instructors.

INF 102 CONCEPTS OF PROG. LANGS ADVERSITY. Instructors: James Jones Copyright Instructors. INF 102 CONCEPTS OF PROG. LANGS ADVERSITY Instructors: James Jones Copyright Instructors. Approaches to failure Let it fail Good in development: understand failure mode Defend against the possible and

More information

while (rs.next()) { String[] temp_array = {"","",""}; int prodid = rs.getint(1); temp_array[0] = ""+prodid;

while (rs.next()) { String[] temp_array = {,,}; int prodid = rs.getint(1); temp_array[0] = +prodid; import java.sql.connection; import java.sql.drivermanager; import java.sql.resultset; import java.sql.sqlexception; import java.sql.statement; import java.util.arraylist; import java.util.scanner; public

More information

Strut2 jasper report plugin - War deployment

Strut2 jasper report plugin - War deployment Strut2 jasper report plugin - War deployment Hi guys, if you use jasper report in a web app with Struts2 and you deploy it in Tomcat with unpacked option set to true, it doesn't work because it's impossible

More information

e-pg Pathshala Subject: Computer Science Paper: Web Technology Module: JDBC INTRODUCTION Module No: CS/WT/26 Quadrant 2 e-text

e-pg Pathshala Subject: Computer Science Paper: Web Technology Module: JDBC INTRODUCTION Module No: CS/WT/26 Quadrant 2 e-text e-pg Pathshala Subject: Computer Science Paper: Web Technology Module: JDBC INTRODUCTION Module No: CS/WT/26 Quadrant 2 e-text Learning Objectives This module gives an introduction about Java Database

More information

JAVA SERVLET. Server-side Programming INTRODUCTION

JAVA SERVLET. Server-side Programming INTRODUCTION JAVA SERVLET Server-side Programming INTRODUCTION 1 AGENDA Introduction Java Servlet Web/Application Server Servlet Life Cycle Web Application Life Cycle Servlet API Writing Servlet Program Summary 2 INTRODUCTION

More information

Algorithmic Verification of Procedural Programs in the Presence of Code Variability

Algorithmic Verification of Procedural Programs in the Presence of Code Variability Algorithmic Verification of Procedural Programs in the Presence of Code Variability Siavash Soleimanifard School of Computer Science and Communication KTH Royal Institute of Technology Stockholm Doctoral

More information