User talk:Motorockers~enwiki

import view.*; public class Controller {

public static void main(String[] args) { StudentSystemView sv=new StudentSystemView; sv.menu;

}

}

package bean;

public class PG extends Student { private double termPaper; private double thesisMarks; public PG { super; // TODO Auto-generated constructor stub }	public PG(int regNo, String name, double marks,double termPaper,double thesisMarks) { super(regNo, name, marks); this.termPaper=termPaper; this.thesisMarks=thesisMarks; }	public double getTermPaper { return termPaper; }	public void setTermPaper(double termPaper) { this.termPaper = termPaper; }	public double getThesisMarks { return thesisMarks; }	public void setThesisMarks(double thesisMarks) { this.thesisMarks = thesisMarks; }

}

-- package bean;

public abstract class Student { private int regNo; private String name; private double marks;

public Student { super; } public Student(int regNo, String name, double marks) { super; this.regNo = regNo; this.name = name; this.marks = marks; } public int getRegNo { return regNo; } public void setRegNo(int regNo) { this.regNo = regNo; } public String getName { return name; } public void setName(String name) { this.name = name; } public double getMarks { return marks; } public void setMarks(double marks) { this.marks = marks; }

} - package dao; import java.sql.*; public class StudentDAO { public Connection doConnect{ Connection con=null; try { Class.forName("oracle.jdbc.driver.OracleDriver"); String url="jdbc:oracle:thin:@172.0.0.15:1521:orcl"; con=DriverManager.getConnection(url,"scott","tiger"); } catch (ClassNotFoundException e) { e.printStackTrace; }			catch(SQLException sqe){System.out.println(sqe);} return con; }

}

-- package model; import dao.*; import bean.*; import java.sql.*; import java.util.*;

public class StudentModel { public int persist(Student s){ String sql=null; if(s instanceof UG ){ UG u=(UG)s; sql="insert into DRStudentUG(regno,name,marks,projMarks) values(" + u.getRegNo + ",'" + u.getName + "'," + u.getMarks + "," + u.getProjMarks + ")"; System.out.println(sql); }		else{ PG p=(PG)s; sql="insert into DRStudentPG(regno,name,marks,termPaper,thesisMarks) values(" + p.getRegNo + ",'" +p.getName + "'," + p.getMarks + "," + p.getTermPaper + "," + p.getThesisMarks+ ")"; System.out.println(sql); }		int x=0; try{ Connection con=new StudentDAO.doConnect; Statement st=con.createStatement; x=st.executeUpdate(sql); }catch(SQLException sqe){System.out.println(sqe);} return x;	} public int updateStudent(int regno,double newMarks){ int x=0; try{ Connection con=new StudentDAO.doConnect; Statement st=con.createStatement; String sql="update DRStudentUG set marks=" + newMarks + " where regno= " + regno ; x=st.executeUpdate(sql); if(x==0){ sql="update DRStudentPG set marks=" + newMarks + " where regno= " + regno ; x=st.executeUpdate(sql); }		}catch(SQLException sqe){System.out.println(sqe);} return x;	} public int deleteStudent(int regno){ int x=0; try{ Connection con=new StudentDAO.doConnect; Statement st=con.createStatement; String sql="delete from DRStudentUG where regno=" + regno; x=st.executeUpdate(sql); if(x==0){ sql="delete from DRStudentPG where regno=" + regno; x=st.executeUpdate(sql); }		}catch(SQLException sqe){} return x;	} public ArrayList getStudents(String type){ ArrayList al=new ArrayList; try{ Connection con=new StudentDAO.doConnect; Statement st=con.createStatement; String sql=null; if(type.equals("UG")) sql="select * from DRStudentUG"; else sql="select * from DRStudentPG"; ResultSet rs=st.executeQuery(sql); while(rs.next) if(type.equals("UG")){ al.add(new UG(rs.getInt(1),rs.getString(2),rs.getDouble(3),rs.getDouble(4))); }				else{ al.add(new PG(rs.getInt(1),rs.getString(2),rs.getDouble(3),rs.getDouble(4),rs.getDouble(5))); }		}catch(SQLException sqe){System.out.println(sqe);} return al; }

}

-- package view; import java.io.*;

import bean.*; import java.util.*; import model.*; import static java.lang.System.*;

public class StudentSystemView { public void menu{ try{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); boolean flag=authenticateAdmin; if(flag){ String cont="Yes"; do{ out.println("1 : Insert UG Student..."); out.println("2 : Insert PG Student..."); out.println("3 : Delete a Student..."); out.println("4 : Display all UG Student..."); out.println("5 : Display all PG Student..."); out.println("\nEnter you choice..."); int i=Integer.parseInt(br.readLine); switch(i){ case 1 : getUGStudent; break; case 2:    getPGStudent; break; case 3: doDelete; break; case 4: displayUG; break; case 5:     displayPG; break; default : out.println("Invalid Choice..."); }				System.out.println("Want to Continue[Yes | No"); cont=br.readLine; }while(cont.equalsIgnoreCase("Yes")); System.out.println("Bye....."); }		}catch(IOException io){} }	public boolean authenticateAdmin{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); out.println("Enter Admin uname and password...."); boolean flag=false; try { String uname=br.readLine; String pass=br.readLine; ValidateModel v=new ValidateModel; flag=v.isValid(uname, pass); if(flag) out.println("Welcome " + uname + " you are Authenticated..."); else out.println("You are Not Authenticated..."); } catch (IOException e) { e.printStackTrace; }			return flag; }		public void   getUGStudent{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); try{ out.println("Give UG Student Details ...."); out.print("Regno : "); int no=Integer.parseInt(br.readLine); out.println("Name : "); String nm=br.readLine; out.print(" Marks : "); double marks=Double.parseDouble(br.readLine); out.print(" Project Marks : "); double proj=Double.parseDouble(br.readLine); UG u=new UG(no,nm,marks,proj); int x=new StudentModel.persist(u); System.out.println( x + " UG Student Inserted...."); }catch(IOException io){} }		public void   getPGStudent{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); try{ out.println("Give PG Student Details ...."); out.print("Regno : "); int no=Integer.parseInt(br.readLine); out.println("Name : "); String nm=br.readLine; out.print(" Marks : "); double marks=Double.parseDouble(br.readLine); out.print(" Term Paper Marks : "); double tp=Double.parseDouble(br.readLine); out.print(" Thesis Marks : "); double tm=Double.parseDouble(br.readLine); PG p=new PG(no,nm,marks,tp,tm); int x=new StudentModel.persist(p); System.out.println( x + " PG Student Inserted...."); }catch(IOException io){} }		public void displayUG{ ArrayList al=new StudentModel.getStudents("UG"); System.out.println("The UG Students are : "); Iterator it=al.iterator; while(it.hasNext){ UG u=(UG)it.next; out.println(u.getRegNo + " " + u.getName + " " + u.getMarks + " " + u.getProjMarks); }		}		public void displayPG{ ArrayList al=new StudentModel.getStudents("PG"); System.out.println("The PG Students are : "); Iterator it=al.iterator; while(it.hasNext){ PG u=(PG)it.next; out.println(u.getRegNo + " " + u.getName + " " + u.getMarks + " " + u.getTermPaper + " " + u.getThesisMarks); }		}		public void doDelete{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); try{ out.print("Regno : "); int no=Integer.parseInt(br.readLine); int x=new StudentModel.deleteStudent(no); out.println(x + " Student deleted...."); }catch(IOException io){} }	}

--- package bean;

public class UG extends Student { private double projMarks;

public double getProjMarks { return projMarks; }

public UG { super; // TODO Auto-generated constructor stub }

public UG(int regNo, String name, double marks,double projMarks) { super(regNo, name, marks); this.projMarks=projMarks; }

public void setProjMarks(double projMarks) { this.projMarks = projMarks; }

}

--- package model; import java.sql.*; import dao.*; public class ValidateModel { public boolean isValid(String uname,String pass){ boolean flag=false; try{ Connection con=new StudentDAO.doConnect; Statement st=con.createStatement; String sql="select * from validUser where uname='" + uname + "' and pass='" + pass + "'"; ResultSet rs=st.executeQuery(sql); flag=rs.next; }catch(SQLException sqe){} return flag; } }

package model; import java.sql.*; import dao.*; public class ValidateModel { public boolean isValid(String uname,String pass){ boolean flag=false; try{ Connection con=new StudentDAO.doConnect; Statement st=con.createStatement; String sql="select * from validUser where uname='" + uname + "' and pass='" + pass + "'"; ResultSet rs=st.executeQuery(sql); flag=rs.next; }catch(SQLException sqe){} return flag; } }

class Cbt extends Item { int durplay; Cbt{ super; } public Cbt(int itemno,String itemname,int itemprice,int durplay) { super(itemno,itemname,itemprice); this.durplay = durplay; }

public int getDurplay { return durplay; }

public void setDurplay(int durplay) { this.durplay = durplay; }

}

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.sql.*;

public class Controller { public static void main(String args[]){ Book item=null; Cbt h=null; String m=null; char ch='a'; int choice=-1; Model model=new Model; InputStreamReader isr=new InputStreamReader(System.in); BufferedReader br=new BufferedReader(isr); View view =new View; do{ view.showMenu; try{ choice=Integer.parseInt(br.readLine); }			catch(IOException ie){ System.out.println(ie); }			if(choice==1){ view.authenticate1; try{ m=br.readLine; }				catch(IOException ie){ System.out.println(ie); }				if(m.equals("satya")){ view.authenticate2; try{ m=br.readLine; }				catch(IOException ie){ System.out.println(ie); }}				if(m.equals("nn")) {					view.enquiry; try{ choice=Integer.parseInt(br.readLine); }		    	catch(IOException ie){ System.out.println(ie); }			   if(choice==1){ view.benquiry; try{ choice=Integer.parseInt(br.readLine); }				  catch(IOException ie){ System.out.println(ie); }				if(choice==1){ item=view.insertMenu1; boolean b=model.insert1(item); view.displayMessage(b); }				else if(choice==2){ h=view.insertMenu2; boolean b=model.insert2(h); view.displayMessage(b); }			}		 else if(choice==2){ view.benquiry; try{ choice=Integer.parseInt(br.readLine); }					catch(IOException ie){ System.out.println(ie); }		if(choice==1){ int id=view.retrieveMenu; ResultSet rs=model.retrieve1(id); try{ view.show1(rs.next,rs); }			catch(SQLException sqe){ System.out.println(sqe); }}        else if(choice==2){ int id=view.retrieveMenu; ResultSet rs=model.retrieve2(id); try{ view.show2(rs.next,rs); }				catch(SQLException sqe){ System.out.println(sqe); }       }		 }}}		else if(choice==2){ view.benquiry; try{ choice=Integer.parseInt(br.readLine); }						catch(IOException ie){ System.out.println(ie); }						if(choice==1){ int d=view.retrieveMenu; ResultSet rs=model.retrieve1(d); try{ view.show1(rs.next,rs); }							catch(SQLException sqe){ System.out.println(sqe); }						}	       else if(choice==2){ int id=view.retrieveMenu; ResultSet rs=model.retrieve2(id); try{ view.show2(rs.next,rs); }				catch(SQLException sqe){ System.out.println(sqe); }	       }   			 }ch=view.continueMenu; }while(ch=='y'); }	} -- import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement;

class DAO { Connection con; Statement stmt; private static DAO instance=new DAO; public static DAO getInstance{ return instance; }	private DAO{ try{ Class.forName("oracle.jdbc.driver.OracleDriver"); con=DriverManager.getConnection("jdbc:oracle:thin:@172.0.0.15:1521:orcl","scott","tiger"); stmt=con.createStatement; }		catch(ClassNotFoundException cfe){ System.out.println(cfe); }		catch(SQLException sqe){ System.out.println(sqe); }	}	public int insertRecord1(int itemno,String itemname,int itemprice,String publname){ int n=-1; try{ n=stmt.executeUpdate("insert into book_465768 values("+itemno+",'"+itemname+"',"+itemprice+",'"+publname+"')"); }		catch(SQLException sqe){ System.out.println(sqe); }		return n;	} public int insertRecord2(int itemno,String itemname,int itemprice,int durplay){ int n=-1; try{ n=stmt.executeUpdate("insert into cbt_465768 values("+itemno+",'"+itemname+"',"+itemprice+","+durplay+")"); }		catch(SQLException sqe){ System.out.println(sqe); }		return n;	} public ResultSet retrieveRecord1(int id){ ResultSet rs=null; try{ rs=stmt.executeQuery("select * from book_465768 where itemno="+id); }		catch(SQLException sqe){ System.out.println(sqe); }		finally{ return rs; }	}	public ResultSet retrieveRecord2(int id){ ResultSet rs=null; try{ rs=stmt.executeQuery("select * from cbt_465768 where itemno="+id); }		catch(SQLException sqe){ System.out.println(sqe); }		finally{ return rs; }	} protected void finalize{ try{ stmt.close; con.close; } catch(SQLException sqe){ sqe.printStackTrace; }}

} ---

abstract class Item{ int itemno; String itemname; int itemprice; Item{ super; }	public Item(int itemno, String itemname, int itemprice) { super; this.itemno = itemno; this.itemname = itemname; this.itemprice = itemprice; }	public int getItemno { return itemno; }	public void setItemno(int itemno) { this.itemno = itemno; }	public String getItemname { return itemname; }	public void setItemname(String itemname) { this.itemname = itemname; }	public int getItemprice { return itemprice; }	public void setItemprice(int itemprice) { this.itemprice = itemprice; }

}

import java.io.*; import java.sql.*; class Model { DAO dao=DAO.getInstance; public boolean insert1(Book book){ int itemno=book.getItemno; String itemname=book.getItemname; int itemprice=book.getItemprice; String publname=book.getPublname; int n=dao.insertRecord1(itemno,itemname,itemprice,publname); if(n!=0) return true; else return false; }		public boolean insert2(Cbt h){ int itemno=h.getItemno; String itemname=h.getItemname; int itemprice=h.getItemprice; int durplay=h.getDurplay; int n=dao.insertRecord2(itemno,itemname,itemprice,durplay); if(n!=0) return true; else return false; }		public ResultSet retrieve1(int id){ ResultSet rs=dao.retrieveRecord1(id); return rs; }		public ResultSet retrieve2(int id){ ResultSet rs=dao.retrieveRecord2(id); return rs; }

}

--- import java.io.*; import java.sql.*;

public class View {

public void showMenu{ System.out.println("1.adminstrator"); System.out.println("2.Nonadminstrator"); System.out.println("Enter your choice:"); }	public void authenticate1{ System.out.println("Enter User Name:"); }	public void authenticate2{ System.out.println("Enter Password"); }	public void enquiry{ System.out.println("1.write"); System.out.println("2.read"); System.out.println("Enter your choice:"); }	public void benquiry{ System.out.println("1.Book"); System.out.println("2.Cbt"); System.out.println("Enter your choice:"); }

public Book insertMenu1{ int itemno=0; String itemname=null; int itemprice=0; String publname=null; Book item=null; try{ item=new Book; InputStreamReader isr=new InputStreamReader(System.in); BufferedReader br=new BufferedReader(isr); System.out.print("Insert Item no:"); itemno=Integer.parseInt(br.readLine); item.setItemno(itemno); System.out.print("Insert Item name :"); itemname=br.readLine; item.setItemname(itemname); System.out.print("Insert Item Price :"); itemprice=Integer.parseInt(br.readLine); item.setItemprice(itemprice); System.out.print("Insert Publisher Name :"); publname=br.readLine; item.setPublname(publname); }		catch(IOException sqe){ System.out.println(sqe); }		finally{ return item; }	}	public Cbt insertMenu2{ int itemno=0; String itemname=null; int itemprice=0; int durplay=0; Cbt item=null; try{ item=new Cbt; InputStreamReader isr=new InputStreamReader(System.in); BufferedReader br=new BufferedReader(isr); System.out.print("Insert Item no:"); itemno=Integer.parseInt(br.readLine); item.setItemno(itemno); System.out.print("Insert Item name :"); itemname=br.readLine; item.setItemname(itemname); System.out.print("Insert Item Price :"); itemprice=Integer.parseInt(br.readLine); item.setItemprice(itemprice); System.out.print("Insert Training Duration :"); durplay=Integer.parseInt(br.readLine); item.setDurplay(durplay); }		catch(IOException sqe){ System.out.println(sqe); }		finally{ return item; }	}	public int retrieveMenu{ int id=-1; InputStreamReader isr=new InputStreamReader(System.in); BufferedReader br=new BufferedReader(isr); try{ System.out.print("Insert item no:"); id=Integer.parseInt(br.readLine); }		catch(IOException ie){ System.out.println(ie); }		return id; }	public char continueMenu{ char ch='a'; InputStreamReader isr=new InputStreamReader(System.in); BufferedReader br=new BufferedReader(isr); System.out.println("Do you want to continue?y/n"); try{ ch=(char)br.read; }		catch(IOException ie){ System.out.println(ie); }		return ch; }	public void show1(boolean b,ResultSet rs){ if(b==true){ try{ System.out.println(rs.getInt(1)+"  "+rs.getString(2)+"   "+rs.getInt(3)+"  "+rs.getString(4)); }			catch(SQLException sqe){ System.out.println(sqe); }		}		else{ System.out.println("Invalid ID"); }	}	public void show2(boolean b,ResultSet rs){ if(b==true){ try{ System.out.println(rs.getInt(1)+"  "+rs.getString(2)+"   "+rs.getInt(3)+"  "+rs.getInt(4)); }			catch(SQLException sqe){ System.out.println(sqe); }		}		else{ System.out.println("Invalid ID"); }	}	public void displayMessage(boolean b){ if(b==true){ System.out.println("Record successfully inserted"); }		else{ System.out.println("Unble to insert record"); }	} } - package controller; import model.*; import View.*;

public class Main { public static void main(String args[]){ EmployeeManager em=new EmployeeManager; Menu m=new Menu; int optionSelected=0; do{ optionSelected=m.displayMenu(em); }while(optionSelected>=1 && optionSelected<=3); } }

package dao; import java.sql.*; public class Database { Connection c;	PreparedStatement ps; Statement s;	public Database{ try{ Class.forName("oracle.jdbc.driver.OracleDriver"); String url="jdbc:oracle:thin:@172.0.0.15:1521:orcl"; c=DriverManager.getConnection(url,"scott","tiger"); }	catch(SQLException e){System.out.println(e);} catch(ClassNotFoundException ee){System.out.println("Driver Not Available : " + ee);} }	public void updateData{ try{ String query="update emp_139 set salary=salary+(0.30*salary) where salary>=10000 and salary<40000"; if(c!=null){ ps=c.prepareStatement(query);} int ex=ps.executeUpdate; System.out.println("Data updated"); if(ex==0)System.out.println("Updation failed"); }		catch(SQLException e){System.out.println("Updation failed...");} }	public void displayAll{ try{ if(c!=null){ s=c.createStatement; ResultSet rs=s.executeQuery("select * from emp_139"); while(rs.next) System.out.println(rs.getString(1) + "\t" +rs.getDouble(2)); rs.close; }		}		catch(SQLException e){} }	public void copyAll{ try{ if(c!=null){ s=c.createStatement; ResultSet rs=s.executeQuery("create view emp_139_vw1 as select * from emp_139"); //while(rs.next) //System.out.println(rs.getString(1) + "\t" +rs.getDouble(2)); rs.close; }		}		catch(SQLException e){} } } --- package model; import dao.Database;

public class EmployeeManager { public void updateRecord{ Database db= new Database; db.updateData; }	public void displayRecord{ Database db=new Database; db.displayAll; }	public void copyRecord{ Database db=new Database; db.copyAll; } } --- package View; import java.util.*; import model.*;

public class Menu { public int displayMenu(EmployeeManager emp){ Scanner sc=new Scanner(System.in); System.out.println("1. UPDATE DATA"); System.out.println("2. DISPLAY DATA"); System.out.println("3. COPY DATA"); System.out.println("4.display the copied DATA"); System.out.println("Enter choice"); int ch=sc.nextInt; switch(ch){ case 1: emp.updateRecord; break; case 2: emp.displayRecord; break; case 3:emp.copyRecord;break; default: System.out.println("Invalid choice"); }		return ch; } }

Your account will be renamed
Hello,

The developer team at Wikimedia is making some changes to how accounts work, as part of our on-going efforts to provide new and better tools for our users like cross-wiki notifications. These changes will mean you have the same account name everywhere. This will let us give you new features that will help you edit and discuss better, and allow more flexible user permissions for tools. One of the side-effects of this is that user accounts will now have to be unique across all 900 Wikimedia wikis. See the announcement for more information.

Unfortunately, your account clashes with another account also called Motorockers. To make sure that both of you can use all Wikimedia projects in future, we have reserved the name Motorockers~enwiki that only you will have. If you like it, you don't have to do anything. If you do not like it, you can pick out a different name. If you think you might own all of the accounts with this name and this message is in error, please visit Special:MergeAccount to check and attach all of your accounts to prevent them from being renamed.

Your account will still work as before, and you will be credited for all your edits made so far, but you will have to use the new account name when you log in.

Sorry for the inconvenience.

Yours, Keegan Peterzell Community Liaison, Wikimedia Foundation 01:58, 20 March 2015 (UTC)

Renamed
 This account has been renamed as part of single-user login finalisation. If you own this account you can |log in using your previous username and password for more information. If you do not like this account's new name, you can choose your own using this form after logging in: . -- Keegan (WMF) (talk) 16:35, 22 April 2015 (UTC)