iwt lab program

Upload: rahul-hellsanxel

Post on 08-Apr-2018

258 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/7/2019 IWT lab program

    1/42

    I.T.S ENGINEERINGCOLLEGE

    SESSION: - 2010-2011ODD SEMESTER

    IWT LAB FILE

    SUBMITTED TO: -SUBMITTED BY:-

  • 8/7/2019 IWT lab program

    2/42

    S.NO

    NAME OF PROGRAM DATE REMARKS

    1. Display Resume By UsingHTML

    2. Display Train Time Table ByUsing HTML

    3. Yahoo Sign Up Page

    4. DB Insertion of 3 Fields

    5. XML File for Student

    6. Servlet to Display Current

    Date and Time

    7. DB Connection toMySQL(JDBC)

    8. DB Insertion, Deletion and

    Updation in MySQL(JDBC)

  • 8/7/2019 IWT lab program

    3/42

    Resume

    Resume

    Resume

    Personal Details

    Name:Rahul Prasad

    Address: Faculty center, ALTTC, Rajnagar, GZB

    Age:20 yrs

    Degree:B.Tech Computer Science

    Objective:To excel in the field of Computerengineering in a growth-oriented organization, that enables me to fully utilize

    my technical skills.




  • 8/7/2019 IWT lab program

    4/42

    Education


    Qualification Institute Board/University Year Percentage/Marks

    B.Tech (3rd Year)I.T.S Engg. College,

    Greater NoidaU.P. TechnicalUniversity2009

    B.Tech (2nd Year)I.T.S Engg. College,

    Greater NoidaU.P. Technical

    University2008

    B.Tech (1st Year)I.T.S Engg. College,

    Greater NoidaU.P. Technical

    University2007 td>

    XIIR.K.I. Ghaziabad

    C.B.S.E2006

    XR.K.I. Ghaziabad

    C.B.S.E2004



  • 8/7/2019 IWT lab program

    5/42

    Achievements



    1. . Member of Computer Society of India(C.S.I )

    2. Participated in various Academic activities and

    various other competitions at school & college



    Additional Skills



    Programming skills known:

    1. C,C++,

    2. Matlab 7.0

    3. Visual Studio 6.0,SQL 2003

    5. Micrsoft Powerpoint 2003,Access 2003,Word 2003



  • 8/7/2019 IWT lab program

    6/42

    Extra Curricular Activities



    1. Member of Computer Society of India(C.S.I)

    2. Member of BRILLANZ-Computer Society of I.T.S Engg.

    College, Greater Noida

    3. Playing Badminton

    4. Reading Books

    5. Computer Gaming



  • 8/7/2019 IWT lab program

    7/42

    ResumePersonal Details

    Name: Rahul Prasad

    Address: Faculty center, ALTTC, Rajnagar, GZB

    Age: 20 yrs

    Degree: B.Tech Computer Science

    Objective:

    Intend to build a career with corporate with

    committed and dedicated people, which will help meto explore my-self fully and release my ultimate

    potential and hence contribute in growth of

    organization

    Educational Qualification

    Qualification Institute Board/University Year Percentage/Marks

    B.Tech (3rd

    Year)

    I.T.S Engg. College,

    Greater Noida

    U.P. Technical

    University

    201

    0

    68%

    B.Tech (2nd

    Year)

    I.T.S Engg. College,

    Greater Noida

    U.P. Technical

    University

    200

    9 62.80%

    B.Tech (1st

    Year)

    I.T.S Engg. College,

    Greater Noida

    U.P. Technical

    University

    200

    8 68%

    XIIR.K.I. Ghaziabad

    C.B.S.E200

    6 65%

    X

    R.K.I. Ghaziabad

    C.B.S.E200

    4 65%

  • 8/7/2019 IWT lab program

    8/42

    Achievements

    1. Member of C.S.I(Computer Society of India)

    2. Participated in various Academic activities andvarious other competitions at school & college.

    Additional Skills

    Programming skills known:

    1. C,C++

    2. Matlab 7.0

    3. Visual Studio 6.0

    4. Microsoft PowerPoint 2003,Access 2003,Word 2003

    Extra Curricular Activities

    1. Member of Computer Society of India(C.S.I)

    2. Member of BRILLANZ-Computer Society of I.T.S Engg. College, Greater Noida

    3. Playing Badminton

    4. Reading Books

    5. Computer Gaming

    Train Time- Table

  • 8/7/2019 IWT lab program

    9/42

    Train Schedule

    Train Schedule

    Train

    Name

    Source

    Destination

    TimeFareArrivalDeparture

    1212

    Jo Bole So Nihaal

    Express

    Amritsar

    Lahore

    12:00 pm

    12:10 pm

    Rs

    120

    6666

    Satriakaal

    Express

    Lahore

    Amritsar

    06:00 pm

    06:10 pmRs

    420

    Train Schedule

  • 8/7/2019 IWT lab program

    10/42

    Trai

    nName Source

    Destinati

    on

    Time

    FareArrival

    Departu

    re

    1212

    Jo Bole So NihaalExpress

    Amritsar

    Lahore12:00pm

    12:10pm

    Rs120

    666

    6Satriakaal Express Lahore Amritsar

    06:00

    pm

    06:10

    pm

    Rs

    420

    DB Insertion of 3 Fields

  • 8/7/2019 IWT lab program

    11/42

  • 8/7/2019 IWT lab program

    12/42

    catch(Exception e)

    {

    status=false;

    }

    }

    }

    class QueryExecute

    {

    ResultSet rs=null;

    ResultSetMetaData rsm=null;

    boolean status=true;

    String querytype=null;

    int count,row,col;

    /** Creates a new instance of QueryExecute */

    public QueryExecute(DBConnect db,String query)

    {

    try

    {

    db.stmt.executeQuery(query);

    querytype="retrieve";

    }

    catch(Exception e)

    {

    try

    {

    count=db.stmt.executeUpdate(query);System.out.println(count);

    querytype="insert";

    }

    catch(Exception e1)

    {

    status=false;

    }

    }

    if(querytype.equals("retrieve")==true)

    {try

    {

    rs=db.stmt.getResultSet();

    rsm=rs.getMetaData();

    rs.last();

    row=rs.getRow();

    col=rsm.getColumnCount();

  • 8/7/2019 IWT lab program

    13/42

    if(row

    alert('Field(s) Inserted');

    DB Insertion

  • 8/7/2019 IWT lab program

    14/42

    function Validate()

    {

    var nam=document.getElementById('name').value;

    var cel=document.getElementById('cell').value;

    var emai=document.getElementById('email').value;

    if(nam=='' || cel=='' || emai==''){

    alert('Field(s) Empty');

    return false;

    }

    else

    {

    if(cel.length!=10)

    {

    alert('Cell Value Length Incorrect');

    return false;

    }

    else

    {

    for(var i=0;i

  • 8/7/2019 IWT lab program

    15/42

    else

    {

    alert('All Information Correct');

    document.frm.action='DBInsert.jsp';

    document.frm.submit();

    return true;}

    }

    }

    }

    Application

    Name:

    Cell No:

    Email Id:

    OUTPUT:

  • 8/7/2019 IWT lab program

    16/42

    Web Form:

    DataBase:

    DB Connection to MySQL

  • 8/7/2019 IWT lab program

    17/42

    DBMS

  • 8/7/2019 IWT lab program

    18/42

    status=false;

    }

    }

    }

    class QueryExecute{

    ResultSet rs=null;

    ResultSetMetaData rsm=null;

    boolean status=true;

    String querytype=null;

    String error=null;

    int count,row,col;

    /** Creates a new instance of QueryExecute */

    public QueryExecute(DBConnect db,String query)

    {

    try

    {

    db.stmt.executeQuery(query);

    querytype="retrieve";

    }

    catch(Exception e)

    {

    try

    {

    count=db.stmt.executeUpdate(query);

    System.out.println(count);querytype="insert";

    }

    catch(Exception e1)

    {

    status=false;

    error=new String(e1.toString());

    }

    }

    if(querytype.equals("retrieve")==true)

    {try

    {

    rs=db.stmt.getResultSet();

    rsm=rs.getMetaData();

    rs.last();

    row=rs.getRow();

    col=rsm.getColumnCount();

  • 8/7/2019 IWT lab program

    19/42

    if(row

  • 8/7/2019 IWT lab program

    20/42

    alert('Connection to DataBase Failed');



    No DataBase Retrieved





    Connection to DataBase Established

    Select Database




  • 8/7/2019 IWT lab program

    21/42

    qe = null;

    if(database!=null)

    {

    db = new DBConnect(username,password,"");

    qe = new QueryExecute(db,"Use "+database);%>

    function OnLoad()

    {

    document.getElementById('user').focus();

    }

    function Validate()

    {

    if(document.getElementById('user').value=="" ||

    document.getElementById('pass').value=="")

    {

    alert('Field(s) Empty');

    return false;

    }

    else{

    return true;

    }

    }

    function Connect()

    {

    if(Validate()==true)

    {

    document.frm.action='DBMSNew.jsp';

    document.frm.submit();}

    else

    {

    OnLoad();

    }

    }

  • 8/7/2019 IWT lab program

    22/42

    OUTPUT:

    Web Form:

    DataBase:

  • 8/7/2019 IWT lab program

    23/42

    DB Insertion in MySQL

    import java.sql.*;

    import javax.sql.*;

    /*

    * DBConnect.java

    *

    * Created on December 20, 2009, 3:04 PM

    *

    * To change this template, choose Tools | Template Manager

    * and open the template in the editor.

    */

    /**

    *

    * @author vasu

    */

    public class DBConnect

    {

  • 8/7/2019 IWT lab program

    24/42

  • 8/7/2019 IWT lab program

    25/42

    }

    catch(Exception e1)

    {

    qestatus=false;

    }

    }if(querytype.equals("retrieve")==true)

    {

    try

    {

    rs=stmt.getResultSet();

    rsm=rs.getMetaData();

    rs.last();

    row=rs.getRow();

    col=rsm.getColumnCount();

    if(row

  • 8/7/2019 IWT lab program

    26/42

    {

    status=false;

    }

    }

    public static void main(String args[]){

    DBConnect db=new DBConnect("root","netwin","mobile");

    db.QueryExecute("insert into dbinsert (name,cell,email) values

    ('ddf','123123','[email protected]')");

    }

    }

    DB Deletion in MySQLimport java.sql.*;

    import javax.sql.*;

    /*

    * DBConnect.java

    *

    * Created on December 20, 2009, 3:04 PM

    *

    * To change this template, choose Tools | Template Manager* and open the template in the editor.

    */

    /**

    *

    * @author vasu

    */

    public class DBConnect

    {

    String user;String pass;

    String dbname;

    String url;

    Connection conn;

    Statement stmt;

    ResultSet rs=null;

  • 8/7/2019 IWT lab program

    27/42

    ResultSetMetaData rsm=null;

    boolean status=true;

    boolean qestatus=true;

    String querytype=null;

    int count,row,col;

    /** Creates a new instance of DBConnect */

    public void CloseConn()

    {

    if(conn!=null)

    {

    try

    {

    conn.close();

    System.out.println("Connection Terminated");

    }

    catch(Exception e1)

    {

    e1.toString();

    }

    }

    }

    void QueryExecute(String query)

    {

    try

    {stmt.executeQuery(query);

    querytype="retrieve";

    }

    catch(Exception e)

    {

    try

    {

    count=stmt.executeUpdate(query);

    System.out.println(count);

    querytype="insert";}

    catch(Exception e1)

    {

    qestatus=false;

    }

    }

    if(querytype.equals("retrieve")==true)

  • 8/7/2019 IWT lab program

    28/42

    {

    try

    {

    rs=stmt.getResultSet();

    rsm=rs.getMetaData();

    rs.last();row=rs.getRow();

    col=rsm.getColumnCount();

    if(row

  • 8/7/2019 IWT lab program

    29/42

    DBConnect db=new DBConnect("root","netwin","mobile");

    db.QueryExecute("delete from dbinsert where sno='3'");

    }

    }

    OUTPUT:

  • 8/7/2019 IWT lab program

    30/42

    DB Updation in MySQL

    import java.sql.*;

    import javax.sql.*;

    /*

    * DBConnect.java*

    * Created on December 20, 2009, 3:04 PM

    *

    * To change this template, choose Tools | Template Manager

    * and open the template in the editor.

    */

    /**

    *

    * @author vasu

    */

    public class DBConnect

    {

    String user;

    String pass;

    String dbname;

    String url;

    Connection conn;

    Statement stmt;

    ResultSet rs=null;ResultSetMetaData rsm=null;

    boolean status=true;

    boolean qestatus=true;

    String querytype=null;

    int count,row,col;

  • 8/7/2019 IWT lab program

    31/42

    /** Creates a new instance of DBConnect */

    public void CloseConn()

    {

    if(conn!=null)

    {

    try{

    conn.close();

    System.out.println("Connection Terminated");

    }

    catch(Exception e1)

    {

    e1.toString();

    }

    }

    }

    void QueryExecute(String query)

    {

    try

    {

    stmt.executeQuery(query);

    querytype="retrieve";

    }

    catch(Exception e)

    {

    try

    {count=stmt.executeUpdate(query);

    System.out.println(count);

    querytype="insert";

    }

    catch(Exception e1)

    {

    qestatus=false;

    }

    }

    if(querytype.equals("retrieve")==true){

    try

    {

    rs=stmt.getResultSet();

    rsm=rs.getMetaData();

    rs.last();

    row=rs.getRow();

  • 8/7/2019 IWT lab program

    32/42

    col=rsm.getColumnCount();

    if(row

  • 8/7/2019 IWT lab program

    33/42

    OUTPUT:

    BEFORE:

    AFTER:

  • 8/7/2019 IWT lab program

    34/42

    XML File for Student

    import javax.swing.*;

    import java.io.*;/*

    * XML.java

    *

    * Created on December 20, 2009, 6:39 PM

    *

    * To change this template, choose Tools | Template Manager

    * and open the template in the editor.

    */

    /***

    * @author vasu

    */

    public class XML

    {

    /** Creates a new instance of XML */

    public XML()

    {

    String name=null,rollno=null,branch=null,year=null;

    String str=null;

    byte c[];

    FileOutputStream fout=null;

    try

    {

    fout=new FileOutputStream("C:\\XML.txt");

    str=new String("\n");

    c=str.getBytes();

    fout.write(c);

    }

    catch(Exception e){

    e.printStackTrace();

    }

    //int c=0;

    do

    {

    name=JOptionPane.showInputDialog("Enter Name:");

  • 8/7/2019 IWT lab program

    35/42

    rollno=JOptionPane.showInputDialog("Enter Roll No:");

    branch=JOptionPane.showInputDialog("Enter Branch:");

    year=JOptionPane.showInputDialog("Enter Year:");

    try

    {str=new String("\n\t");

    c=str.getBytes();

    fout.write(c);

    str=new String("\n\t\t"+name+"");

    c=str.getBytes();

    fout.write(c);

    str=new String("\n\t\t"+rollno+"");

    c=str.getBytes();

    fout.write(c);

    str=new String("\n\t\t"+branch+"");

    c=str.getBytes();

    fout.write(c);

    str=new String("\n\t\t"+year+"");

    c=str.getBytes();

    fout.write(c);

    str=new String("\n\t");c=str.getBytes();

    fout.write(c);

    }

    catch(Exception e)

    {

    e.printStackTrace();

    }

    //System.out.println(c);

    }while((JOptionPane.showConfirmDialog(null,"Do You Wish to Enter

    More??"))==0);//System.out.println(c);

    try

    {

    str=new String("\n");

    c=str.getBytes();

    fout.write(c);

  • 8/7/2019 IWT lab program

    36/42

    fout.close();

    }

    catch(Exception e)

    {

    e.printStackTrace();

    }}

    public static void main(String args[])

    {

    XML xml=new XML();

    }

    }

    OUTPUT:

    XML File Created Automatically :

  • 8/7/2019 IWT lab program

    37/42

    llkasds

    dddd

    aaaa

    ssss

    dddd

    eeee

    ffff

    kkkk

    Servlet to Display Current Date and Time

    /*

    * Time.java

    *

    * Created on December 20, 2009, 9:05 PM

  • 8/7/2019 IWT lab program

    38/42

    */

    /**

    *

    * @author vasu* @version

    */

    import java.io.*;

    import javax.servlet.*;

    import javax.servlet.http.*;

    import java.util.Date;

    public class Time extends HttpServlet

    {

    public void doGet(HttpServletRequest req, HttpServletResponse rsp)throws

    ServletException, IOException

    {

    rsp.setContentType("text/html");

    PrintWriter out = rsp.getWriter();

    Date now = new Date(); // The current date/time

    out.println("");

    out.println(" Time Check ");

    out.println("");

    out.println("

    The time is: " + now + "

    ");out.println("");

    }

    }

    OUTPUT:

  • 8/7/2019 IWT lab program

    39/42

    Yahoo Sign Up Page

  • 8/7/2019 IWT lab program

    40/42

    Yahoo Sign Up Page

    Yahoo Sign Up Page



    Name:

    Sex:

    Select Sex

    Male

    Female

    DOB:



    Sign Up

    Name and Password


  • 8/7/2019 IWT lab program

    41/42

    Requested Id:

    Password

    Retype Password:



    Security

    Questions


    Question 1:

    What is the first name of your favourite uncleWhere did you meet your spouse

    What is your Oldest Cousins Name

    Answer:

    Question 2:

    Where did you spend your honeymoon

    What town was your father born in

    What was your favourite food as a child

  • 8/7/2019 IWT lab program

    42/42

    Answer:




    OUTPUT: