Wt Record

  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Wt Record as PDF for free.

More details

  • Words: 5,267
  • Pages: 108
PROGRAM: css1 test content <style type="text/css"> body { margin:0.5in;background-color:white } ul { list-style-image:url(E:\karthi\web\emperor\23.gif); list-style-position:outside;padding-left:20 } pre { font-family:arial;color:red;background-color:yellow } a { color:red; clear:left } a:link { color:lime

} a:visited { color:firebrick } a:active { color:yellow } p.firsttype:first.letter { color:red } p.firsttype:first-line { font-variant:small-caps }

this is the css1 test content

in order to demonstrate<strong>css1 style sheets i created this test content document,which contains samples of most types of web page content

css1 can impact on a document generally, as well as individual elements such as:

    <pre>
  • lists
  • headers
  • images
  • paragraphs
  • inline paragraphs
  • tables
  • forms and form elements

    css1 can also alter the presentation of certain pseudo-elements such as hypertext links or the first line or character within a line. ther actually isntanything that cant in some way



    OUTPUT:

    RESULT: Thus the html program as be executed successfully and the result is displayed.

    PROGRAM: table examples


    please enter the following information:
    firstname: last name:
    address: city and state:
    primary colors: <select name="colors"> secondary color: <select name="colors2">
    low resolution images: high resolution images:


    OUTPUT:

    RESULT: Thus the html program as be executed successfully and the result is displayed.

    PROGRAM:

    <style type="text/css"> body{background-color:white} #heading{color:yellow;position:absolute;left:15;top:10;font-size:24pt} #heading2{color:black;position:absolute;left:17;top:12;font-size:24pt} <script language="javascript1.2"> over "+item+""; parent.workFrame.document.content.document.write(string); parent.workFrame.document.content.document.close(); } //--> <script language="javascript">

    over" + item + ""; parent.workFrame.content.innerHTML=string; } //--> <map name=menu> <area shape=rect coords="0,0,100,57" href="#test" onMouseOver="change_content('main')"> <area shape=rect coords="101,0,201,57" href="#test" onMouseOver="change_content('page1')"> <area shape=rect coords="202,0,302,57" href="#test" onMouseOver="change_content('page2')"> <area shape=rect coords="303,0,403,57" href="#test" onMouseOver="changecontent('page3')"> <area shape=rect coords="404,0,504,57" href="#test" onMouseOver="change_content ('help')"> <area shape=default href="#test" onMouseOver="change_content('menu page')">

    <span id="heading">welcome <span id="heading2">welcome

    <style type="text/css"> body{ background-color:black;color:yellow; margin: 0.1in 0.4in} h2{color:lime;font-size:48pt; font-family:cursive;font-style:italic

    main body

    starting contents



    OUTPUT:

    RESULT: Thus the html program as be executed successfully and the result is displayed.

    PROGRAM: multimedia

    shelly's first

    song <param name= filename value= "E:\songs\Tamil videos\8.vob"> <embed src="E:\songs\Tamil videos\8.vob">
    a little tune i created using microsoft producer


    OUTPUT:

    RESULT:

    Thus the html program for displaying multimedia elements has been executed successfully and the result is displayed.

    PROGRAM: MULTIMEDIA <style type="text/css"> h1 { color:red; text-align:center; }

    Sri Venkateshwara College



    <param name="filename" value="avp-210.mpg"> <param name="DisplayBackColor" value="&H00F00"> <param name="DisplayForeColor" value="&H000000"> <param name="Rate" value="1.25">


    OUTPUT:

    RESULT: Thus the html program for displaying embedded objects has been executed successfully and the result is displayed.

    PROGRAM: TEXT CONTROLS <style type="text/css"> #formlayout { background-color:aqua; border-color:red; border-style:groove; border-width:6; padding:10;position:absolute;left:10;top:10;width:600 } TD.label { width:150;text-align:right;color:red;font-family:Univers; font-size:18pt } TD.control { text-align:left } INPUT { color:red;font-family:Cursive; font-style:italic;

    font-size:14pt }


    Color Preferences: Blue Red Green
    This image is actually a button
    OUTPUT:

    RESULT: Thus the program to display page elements has been executed successfully.

    PROGRAM:

    simple multiplication <script type="text/javascript"> function multiply() { var number_one=document.the_form.field_one.value; var number_two=document.the_form.field_two.value; var result=number_one*number_two; alert(number_one+"times"+number_two+"is:"+result); }
    Number 1:
    number 2:
    multiply them!


    OUTPUT:

    RESULT: Thus the java script program for multiplying two numbers executed successfully.

    PROGRAM:

    <TITLE>A JavaScript Order Form

    A JavaScript Order Form
















    First Name
    Last Name
    Street Address
    City State ZIP




    Would you like to be on our mailing list? Yes





    Select the Item You Want to Order
    <SELECT NAME="OrderItem">



    Select Quantity of Items to Order


    <SELECT NAME="Quantity">

    Total Due


    <SCRIPT LANGUAGE="JavaScript1.1">
    var x = form.OrderItem.options[form.OrderItem.selectedIndex].value; var y = form.Quantity.options[form.Quantity.selectedIndex].value; var due = (x * y); form.Total.value = due; //-->

    OUTPUT:

    RESULT: Thus the form for ordering products in online as been executed successfully.

    PROGRAM: <script type="text/javascript"> function checkMandatoryFields() { var error_Message=" "; //check text box if(window.document.the_form.the_text.value=="") { error_Message+="please enter your name.\n"; } //check scrolling list if(window.document.the_form.state.selectedIndex<0) { error_Message+="please select a state.\n"; } //check radio button var radio_selected="false"; for(var index=0;index < window.document.the_form.gender.length; index++) { radio_Selected="true"; }

    }

    if(radio_Selected=="false") { error_Message+="Please select a gender.\n"; } if(error_Message==" ") { return true; } else error_Message="please correct the following errors:\n\n"+error_Message; alert(error_Message); return false; } }

    please provide youuur details below



    name:
    State: <select name="state" size="5">
    Gender: female male
    OUTPUT:

    RESULT: Thus the java script for form validation has been executed successfully.

    PROGRAM:

    Enabling and Disable Style Sheet <style> body { background-color:white } h1 { font-size:30pt; font-weight:bold; color:red } h2 { font-size:18pt; color:green; background-color:cyan p

    }

    { font-size:12pt; color:purple; text-indent:30px

    }

    <script language="java script">

    Title

    First Paragraph

    This is the first paragraph,it is very short

    Second Paragraph

    This is the second paragraph,it is short too



    OUTPUT:

    RESULT: Thus the java script for enabling and disabling style sheet has been executed successfully.

    PROGRAM:

    <TITLE>Accessing elements by their id <STYLE type="text/css"> span{color:orange; } .hidden{visibility:hidden;color:green;} <SCRIPT language=”javascript”> function mClick( ) { if(document.all.hid.style.visibility="visible") { document all.hid.style.visibility="visible"; document all.hid.style.backgroundColor=”yellow"; } else { document.all.hid.style.visibility="hidden"; document.all.hid.style.backgroundColor="white"; } } In the month of April there was a lot of <SPAN onClick=’mClick();’>

    precipitation <SPAN class=”hidden" id="hid">
    Precipitation: Water that falls on the earths surface as rain, sleet, snow, etc.

    OUTPUT:

    RESULT: Thus the java script for Accessing elements using their ID has been executed successfully.

    PROGRAM:

    HOME PAGE <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> Untitled Page
    SRI VENKATESWARA COLLEGE




    ABOUT US: <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> Untitled Page

    <style type="text/css"> div#container { position: absolute; left: 50%; top: 50%; width: 1024px; height: 786px; margin-top: -393px; margin-left: -512px; } <style type="text/css"> .SlideMenu1_folder { font-family: Arial; font-size: 11px; text-transform: uppercase; background-color: #2569BC;

    padding-left: 5px; width: 100%; border-style: solid; border-width: 1; border-color: #2569BC; } .SlideMenu1_item { font-family: Arial; font-size: 11px; background-color: #93BEEB; padding-left: 5px; width: 100%; border-style: solid; border-width: 1; border-color: #408FDA; } .SlideMenu1_folder_a { color: #FFFFFF; font-weight: normal; text-decoration: none; } .SlideMenu1_folder_a:hover { color: #FFFFFF;

    font-weight: normal; text-decoration: none; border-color: #408FDA; } .SlideMenu1_item_a { color: #FFFFFF; font-weight: normal; text-decoration: none; } .SlideMenu1_item_a:hover { color: #FFFFFF; font-weight: normal; text-decoration: none; } <script type="text/javascript">
    else if(doc.layers) child=doc.layers; else if(doc.all) elem=doc.all[id]; if(elem) return elem; if(doc.id==id || doc.name==id) return doc; if(doc.childNodes) child=doc.childNodes; if(child) { for(var i=0; i
    var elems=frm[i].elements; for(var j=0; j<elems.length; j++) { elem=FindObject(id,elems[i]); if(elem) return elem; } } } return null; } // --> <script language="JavaScript" type="text/javascript">
    { obj.style.display = "none"; } return false; } //-->
    SRI VENKATESWARA COLLEGE




    ABOUT US
    Sri Venkateswara College of Computer Applications and Management (SVCCAM) was founded in 2007 as a self-financing institution promoted by the Sri Venkateswara Educational and Charitable Trust. This Trust is headed by the founder Commander K.Velu, a former Principal of leading Institutions in Coimbatore till Sep 2006 and Mrs.Megala Velu contributes her service as the Secretary of the Trust.


    MCA.HTML

    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> Untitled Page

    <meta name="generator" content="WYSIWYG Web Builder http://www.wysiwygwebbuilder.com"> <style type="text/css"> .SlideMenu2_folder { font-family: Arial; font-size: 11px; text-transform: uppercase; background-color: #2569BC; padding-left: 5px; width: 100%; border-style: solid; border-width: 1; border-color: #2569BC; } .SlideMenu2_item { font-family: Arial; font-size: 11px; background-color: #93BEEB; padding-left: 5px; width: 100%; border-style: solid; border-width: 1; border-color: #408FDA; } .SlideMenu2_folder_a

    { color: #FFFFFF; font-weight: normal; text-decoration: none; } .SlideMenu2_folder_a:hover { color: #FFFFFF; font-weight: normal; text-decoration: none; border-color: #408FDA; } .SlideMenu2_item_a { color: #FFFFFF; font-weight: normal; text-decoration: none; } .SlideMenu2_item_a:hover { color: #FFFFFF; font-weight: normal; text-decoration: none; } <script type="text/javascript">


    return elem; } } var frm=doc.forms; if(frm) { for(var i=0; i <script language="JavaScript" type="text/javascript">
    { return false; } if (obj.style.display == "none") { obj.style.display = ""; } else { obj.style.display = "none"; } return false; } //-->



    SRI VENKATESWARA COLLEGE
    COURSES
    MCA @ Sri Venkateswara College of Computer Applications and Management is established with the objective of producing talented software engineers.

    The Department is headed by Dr.M.Arthanari who has thirty four years of experience in the educational field. Previously he has served as a principal of Erode Arts College (Autonomous). The department also has eight faculty members in different areas of specialization like database management systems, network security, e-commerce, visual programming and all languages.

    MBA @ Sri Venkateswara College of Computer Applications and Management is established with the objective of producing students of managerial excellence.



    The department has six faculty members in different areas of specialization like Marketing, Human Resource Management, Financial Management, Production & Quality Management and Portfolio Management.


    OUTPUT:

    RESULT: Thus the website has been developed successfully using HTML and DHTML tags.

    PROGRAM:

    FTPS.JAVA

    import java.io.*; import java.net.*; class ftps { public static void main(String args[])throws IOException { Socket s=null; ServerSocket ss=null; DataOutputStream sso=null; DataInputStream sin=null; ss=new ServerSocket(55555); System.out.println("Waiting")

    ;

    s=ss.accept(); sso=new DataOutputStream(s.getOutputStream()); sin=new DataInputStream(s.getInputStream()); String s1; s1=sin.readLine(); FileInputStream fos=new FileInputStream(s1); int str; while((str=fos.read())!=-1) sso.writeBytes(""+(char)str); System.out.println("File has been sent successfully"); sso.close(); s.close(); } }

    FTPC.JAVA import java.io.*; import java.net.*; public class ftpc { public static void main(String args[])throws IOException {

    Socket s=null; DataInputStream si=null; s=new Socket(InetAddress.getLocalHost(),55555); si=new DataInputStream(s.getInputStream()); DataInputStream inp=new DataInputStream(System.in); DataOutputStream so=new

    DataOutputStream(s.getOutputStream());

    String str; System.out.println("\n Enter the filename(path) : "); str=inp.readLine(); so.writeBytes(str); so.writeBytes("\n"); FileOutputStream fos=new FileOutputStream("abc1.txt"); int str1; System.out.println("Transferring the file :"+str+" \n"); while((str1=si.read())!=-1) {

    fos.write((char)str1); System.out.print((char)str1); System.out.println("\n File received successfully");

    si.close(); OUTPUT:

    }

    }

    }

    RESULT: Thus the ftp program for downloading has been executed and file transferred successfully.

    PROGRAM:

    ftp server import java.io.*; import java.net.*; class ftpus { public static void main(String args[])throws IOException { Socket s=null; ServerSocket ss=null; DataOutputStream sso=null; DataInputStream sin=null; ss=new ServerSocket(55555); System.out.println("Waiting")

    ;

    s=ss.accept(); sso=new DataOutputStream(s.getOutputStream()); sin=new DataInputStream(s.getInputStream()); FileOutputStream fos=new FileOutputStream("abc1.txt"); int str1; while((str1=sin.read())!=-1) { fos.write((char)str1); System.out.print((char)str1); } sso.close(); ftp client: import java.io.*;

    s.close();

    }}

    import java.net.*; public class ftpuc { public static void main(String args[])throws IOException { Socket s=null; DataInputStream si=null; s=new Socket(InetAddress.getLocalHost(),55555); si=new DataInputStream(s.getInputStream()); DataInputStream inp=new DataInputStream(System.in); DataOutputStream so=new

    DataOutputStream(s.getOutputStream());

    String str; System.out.println("\n Enter the filename(path) : "); str=inp.readLine(); int i; FileInputStream fos=new FileInputStream(str); while((i=fos.read())!=-1) so.writeBytes(""+(char)i); si.close(); } }

    OUTPUT:

    RESULT: Thus the program has been executed successfully and the result is displayed.

    PROGRAM:

    import java.sql.*; import java.io.*; import java.lang.*;

    public class mark { public String name, rno; public int ma1,ma2,ma3,ma4,ma5,tot,avg;

    private void getdata() throws IOException, SQLException { try { DataInputStream in = new DataInputStream(System.in); System.out.println("Creation Details"); System.out.print("Enter the Name"); name = in.readLine(); System.out.print("Enter the rollno:"); rno = in.readLine(); System.out.print("nter the mark 1"); ma1 = Integer.parseInt(in.readLine()); System.out.print("Enter the mark 2"); ma2 = Integer.parseInt(in.readLine()); System.out.print("Enter the mark 3"); ma3 = Integer.parseInt(in.readLine()); System.out.print("Enter the mark 4");

    ma4 = Integer.parseInt(in.readLine()); System.out.print("Enter the mark 5"); ma5 = Integer.parseInt(in.readLine()); } catch(Exception e) { System.out.println(e); } }

    public void create() throws IOException, SQLException { Connection con; Statement st; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con= DriverManager.getConnection("jdbc:odbc:mark1","",""); st = con.createStatement(); DataInputStream in = new DataInputStream(System.in); getdata(); tot = ma1 + ma2 + ma3 + ma4+ ma5; avg = tot/5; String query = "insert into mark values('"+name+"','"+rno+"',"+ma1+","+ma2+","+ma3+","+ma4+","+ma5+","+t ot+","+avg+");"; st.execute(query);

    st.close(); con.close(); } catch(Exception e) { System.out.println("This roll no : "+rno+" is already created"); } }

    void cancel() { Connection con; Statement st; ResultSet rs; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con= DriverManager.getConnection("jdbc:odbc:mark1","",""); st = con.createStatement(); DataInputStream in = new DataInputStream(System.in); System.out.print("enter roll no:"); rno = in.readLine(); String query1 = "delete * from mark where rno = '"+rno+"' "; st.executeUpdate(query1); System.out.println("The acc no: "+rno+" is canceled"); st.close();

    } catch(Exception ex) { System.out.println("Exception :"+ex); } }

    void read() { Connection con; Statement st; ResultSet rs; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con= DriverManager.getConnection("jdbc:odbc:mark1","",""); st = con.createStatement(); String query = "select * from mark order by rno;"; rs = st.executeQuery(query); System.out.println("\n\tName\tRollno\tmark1\tmark2\tmark3\tmark4\tmark5\tTotal\t Average");

    while(rs.next()) { name = rs.getString("name"); rno = rs.getString("rno"); ma1 = Integer.parseInt(rs.getString("ma1"));

    ma2 = Integer.parseInt(rs.getString("ma2")); ma3 = Integer.parseInt(rs.getString("ma3")); ma4 = Integer.parseInt(rs.getString("ma4")); ma5 = Integer.parseInt(rs.getString("ma5")); tot = Integer.parseInt(rs.getString("tot")); avg = Integer.parseInt(rs.getString("avg"));

    System.out.println('\t'+name+'\t'+rno+'\t'+ma1+'\t'+ma2+'\t'+ma3+'\t'+ma4+'\t' +ma5+'\t'+tot+'\t'+avg); } rs.close(); st.close(); con.close();

    } catch(Exception ex) { System.out.println("Exception:"+ex); } }

    void update() { Connection con; Statement st; ResultSet rs; try

    { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con= DriverManager.getConnection("jdbc:odbc:mark1","",""); st = con.createStatement(); DataInputStream in = new DataInputStream(System.in); System.out.print("enter the name"); name = in.readLine(); System.out.print("Enter the rollno:"); rno = in.readLine(); String query = "update mark set name = '"+name+"',rno = '"+rno+"' where no = '"+rno+"'"; st.executeUpdate(query); System.out.println("The roll no"+rno+" is Updated"); st.close(); con.close(); }

    catch(Exception e) { System.out.println("Exception"+e); } }

    public static void main(String[] args) throws IOException { DataInputStream in = new DataInputStream(System.in); try

    { int choice = 0; String flag = "y"; mark obj = new mark();

    while(flag=="y") { System.out.println("1.creation"); System.out.println("2.cancelation"); System.out.println("3.Updation"); System.out.println("4.Display"); System.out.println("Type Other Keys to Exit"); System.out.println("Enter the Choice"); choice = Integer.parseInt(in.readLine()); switch(choice) { case 1: obj.create(); break; case 2: obj.cancel(); break; case 3: obj.update(); break;

    case 4: obj.read(); break; default: System.exit(0); } } } catch(Exception e) {System.out.println("Exception"+e); } } }

    OUTPUT:

    RESULT: Thus the program has been executed successfully and the result is displayed.

    PROGRAM: import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.sql.*; public class ProductInfo extends JFrame implements ActionListener { /*Declare the variables to create the application interface for the Product Information application*/ JLabel heading, id, desc, rate, quantity, unit_of_msr, empty_label,error; JTextField idField, descField, rateField, quantityField, unit_of_msrField; JButton insert, update, delete, clear, exit; GridBagLayout gbl; GridBagConstraints gbc; JComboBox idCombo; Connection con; PreparedStatement stat; Statement stmt; ResultSet rs; Font f; JPanel jp1; /*Define the constructor for the Product Information application*/ public ProductInfo() {

    setTitle("Product Information"); setSize(600, 300); /*Register the WindowListener interface to define the windowClosing() method*/ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { System.exit(0); } }); /*Initialize the JPanel object*/ jp1=new JPanel(); /*Set the BorderLayout as the layout manager*/ getContentPane().setLayout(new BorderLayout()); /*Initialize the GridBagLayout object*/ gbl = new GridBagLayout(); /*Initialize the GridBagConstraints object*/ gbc = new GridBagConstraints(); jp1.setLayout(gbl); f = new Font("Monospaced", Font.BOLD, 24); gbc.gridx = 1; gbc.gridy = 0; gbc.gridwidth = 3; /*Initialize the JLabel object to set the caption for the application*/ heading = new JLabel("Product Information"); /*Set the font for the caption*/

    heading.setFont(f); /*Add the caption to the Panel*/ jp1.add( heading, gbc); gbc.gridx = 0; gbc.gridy = 1; gbc.gridwidth = 5; empty_label = new JLabel(""); empty_label.setFont(f); jp1.add( empty_label, gbc); gbc.gridx = 1; gbc.gridy = 2; gbc.gridwidth = 1; /*Initialize the id JLabel object*/ id = new JLabel("ID", SwingConstants.LEFT); /*Add the label, id to the panel*/ jp1.add( id, gbc); gbc.gridx = 2; gbc.gridy = 2; gbc.gridwidth = 1; /*Initialize the idField JTextField object*/ idField = new JTextField(10); /*Add the JtextField object, idField to the panel*/ jp1.add( idField, gbc); gbc.gridx = 3; gbc.gridy = 2; gbc.gridwidth = 1;

    /*Initialize the idCombo JComboBox object*/ idCombo = new JComboBox(); /*Set the editable option of idCombo object to false*/ idCombo.setEditable(false); /*Add the JComboBox object, idCombo to the panel*/ jp1.add(idCombo, gbc); gbc.gridx = 1; gbc.gridy = 3; gbc.gridwidth = 1; /*Initialize the desc JLabel object*/ desc = new JLabel("Description", SwingConstants.LEFT); /*Add the desc JLabel object to the panel*/ jp1.add( desc, gbc); gbc.gridx = 2; gbc.gridy = 3; gbc.gridwidth = 2; /*Initialize the descField JTextField object*/ descField = new JTextField(20); /*Add the descField JTextField object to the panel*/ jp1.add( descField, gbc); gbc.gridx = 1; gbc.gridy = 4; gbc.gridwidth = 1; /*Initialize the rate JLabel object*/ rate = new JLabel("Rate", SwingConstants.LEFT); /*Add the rate JLabel object to the panel*/

    jp1.add( rate, gbc); gbc.gridx = 2; gbc.gridy = 4; gbc.gridwidth = 2; /*Initialize the rateField JTextField object*/ rateField = new JTextField(20); /*Add the rateField object to panel*/ jp1.add( rateField, gbc); gbc.gridx = 1; gbc.gridy = 5; gbc.gridwidth = 1; /*Initialize the quantity JTextField object*/ quantity = new JLabel("Quantity", SwingConstants.LEFT); /*Add the quantity object to panel*/ jp1.add( quantity, gbc); gbc.gridx = 2; gbc.gridy = 5; gbc.gridwidth = 2; /*Initialize the quantityField JTextField object*/ quantityField = new JTextField(20); /*Add the quantityField object to panel*/ jp1.add( quantityField, gbc); gbc.gridx = 1; gbc.gridy = 6; gbc.gridwidth = 1; /*Initialize the unit_of_msr JLabel object*/

    unit_of_msr = new JLabel("Unit of Measurement ",SwingConstants.LEFT); /*Add the unit_of_msr object to panel*/ jp1.add( unit_of_msr, gbc); gbc.gridx = 2; gbc.gridy = 6; gbc.gridwidth = 2; /*Initialize the unit_of_msrField JTextField object*/ unit_of_msrField = new JTextField(20); /*Add the unit_of_msrField object to panel*/ jp1.add( unit_of_msrField, gbc); gbc.gridx = 0; gbc.gridy = 7; gbc.gridwidth = 1; /*Initialize the insert JButton object*/ insert = new JButton("Insert"); /*Register ActionListener on insert JButton object*/ insert.addActionListener(this); /*Add the insert object to the panel*/ jp1.add( insert, gbc); gbc.gridx = 1; gbc.gridy = 7; gbc.gridwidth = 1; /*Initialize the update JButton object*/ update = new JButton("Update"); /*Register ActionListener on update JButton object*/ update.addActionListener(this);

    /*Add update object to panel*/ jp1.add( update, gbc); gbc.gridx = 2; gbc.gridy = 7; gbc.gridwidth = 1; /*Initialize the delete JButton object*/ delete = new JButton("Delete"); /*Register ActionListener on delete JButton object*/ delete.addActionListener(this); /*Add delete object to panel*/ jp1.add( delete, gbc); gbc.gridx = 3; gbc.gridy = 7; gbc.gridwidth = 1; /*Initialize the clear JButton object*/ clear = new JButton("Clear"); /*Register ActionListener on clear JButton object*/ clear.addActionListener(this); /*Add the clear JButton object to panel*/ jp1.add( clear, gbc); gbc.gridx = 4; gbc.gridy = 7; gbc.gridwidth = 1; /*Initialize the exit JButton object*/ exit = new JButton("Exit"); /*Register ActionListener on exit JButton object*/

    exit.addActionListener(this); /*Add the exit JButton object to panel*/ jp1.add( exit, gbc); /*Initialize the error JLabel object*/ error = new JLabel(""); /*Add jp1 JPanel object in the center of the contentpane*/ getContentPane().add(jp1,"Center"); /*Add error JLabel object to the contentpane*/ getContentPane().add(error,"South"); try { /*Initialize and load JDBC-ODBC bridge driver*/ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); /*Connect to a data source*/ con = DriverManager.getConnection("jdbc:odbc:qw"); /*Create a Statement object*/ stmt = con.createStatement(); /*Retrieve the rows from the product table and store them in the result set object rs*/ rs = stmt.executeQuery("SELECT p_id FROM product"); /*Display the p_id values in the idCombo object*/ while (rs.next()) { idCombo.addItem(Integer.toString(rs.getInt(1))); /*Close the Connection object*/ con.close(); }

    }

    catch(Exception e) { System.out.println("Error : "+e); } idCombo.addActionListener(this); } public void actionPerformed(ActionEvent ae) { if(ae.getActionCommand() == "Exit") /*Terminate the execution of the application*/ System.exit(0); if(ae.getActionCommand() == "Delete") { /*Delete the selected row from the product table*/ try { /*Initialize the con Connection object */ con = DriverManager.getConnection("jdbc:odbc:qw"); /*Initialize the stat PreparedStatement object to delete a row*/ stat = con.prepareStatement("DELETE from Product WHERE p_id = ?"); String selected_id = idCombo.getSelectedItem().toString(); int id = Integer.parseInt(selected_id); stat.setInt(1, id); /*Execute the query*/ stat.executeUpdate(); /*Close the connection*/

    con.close(); /*Remove ActionListener from idCombo JComboBox object*/ idCombo.removeActionListener(this); /*Initialize the con Connection object*/ con = DriverManager.getConnection("jdbc:odbc:qw"); /*Initialize the stmt Statement object*/ stmt = con.createStatement(); /*Store all the rows of the product table in the rs ResultSet object*/ rs = stmt.executeQuery("SELECT p_id FROM product"); /*Remove all the elements from the idCombo JcomboBox object*/ idCombo.removeAllItems(); while (rs.next()) idCombo.addItem(Integer.toString(rs.getInt(1))); con.close(); idCombo.addActionListener(this); idField.setText(""); descField.setText(""); rateField.setText(""); quantityField.setText(""); unit_of_msrField.setText(""); error.setText("Row Deleted"); } catch(Exception e) { System.out.println("Error " + e ); error.setText("Row cannot be deleted");

    } } if(ae.getActionCommand() == "Insert") { //Insert a row in the product table try { con = DriverManager.getConnection("jdbc:odbc:qw"); stat = con.prepareStatement("INSERT INTO Product VALUES(?, ?, ?, ?, ?)"); String id = idField.getText(); String description = descField.getText(); String rate = rateField.getText(); String quantity = quantityField.getText(); String unit_of_msr = unit_of_msrField.getText(); stat.setInt(1, Integer.parseInt(id)); stat.setString(2, description); stat.setDouble(3, Double.parseDouble(rate)); stat.setInt(4, Integer.parseInt(quantity)); stat.setString(5, unit_of_msr); /*Execute the INSERT statement*/ stat.executeUpdate(); con.close(); idCombo.removeActionListener(this); con = DriverManager.getConnection("jdbc:odbc:qw"); stmt = con.createStatement(); rs = stmt.executeQuery("SELECT p_id FROM product");

    idCombo.removeAllItems(); while (rs.next()) /*Refresh the id values in the idCombo JComboBox after inserting a new row*/ idCombo.addItem(Integer.toString(rs.getInt(1))); con.close(); idCombo.addActionListener(this); error.setText("Row Inserted"); } catch(Exception e) { System.out.println("Error1 "+e); error.setText("Row cannot be inserted"); } } if(ae.getSource() == idCombo) { /*Display the row corresponding the id selected in the idCombo combobox*/ try { con = DriverManager.getConnection("jdbc:odbc:qw"); String selected_id = idCombo.getSelectedItem().toString(); Integer.parseInt(selected_id);

    int id =

    stmt = con.createStatement(); rs = stmt.executeQuery("SELECT p_desc, p_rate, p_qty, WHERE p_id = " + id); rs.next(); idField.setText(selected_id);

    unit_of_msr FROM product

    descField.setText(rs.getString(1)); rateField.setText(Double.toString(rs.getDouble(2))); quantityField.setText(Integer.toString(rs.getInt(3))); unit_of_msrField.setText(rs.getString(4)); con.close(); } catch(Exception e) { System.out.println("Error " + e); } } if(ae.getActionCommand()=="Update") { try { con = DriverManager.getConnection("jdbc:odbc:qw"); /*Initialize the stat PreparedStatement object to update a row in the product table*/ stat = con.prepareStatement("UPDATE Product SET p_desc = ?, p_rate = ?, p_qty = ?, unit_of_msr = ? where p_id = ?"); String description = descField.getText(); String rate = rateField.getText(); String quantity = quantityField.getText(); String unit_of_msr = unit_of_msrField.getText(); String id_selected = idField.getText(); int id = Integer.parseInt(id_selected); stat.setString(1, description); stat.setDouble(2, Double.parseDouble(rate));

    stat.setInt(3, Integer.parseInt(quantity)); stat.setString(4, unit_of_msr); stat.setInt(5, id); /* Execute the UPDATE statement*/ stat.executeUpdate(); con.close(); error.setText("Row Updated"); } catch(Exception e) { System.out.println("Error " + e ); error.setText("Cannot update the row"); } } if(ae.getActionCommand() == "Clear") { /*Clear the contents of all the fields*/ idField.setText(""); descField.setText(""); rateField.setText(""); quantityField.setText(""); unit_of_msrField.setText(""); } } public static void main(String args[]) {

    ProductInfo p = new ProductInfo(); p.show(); } }

    OUTPUT:

    RESULT: Thus the program has been executed successfully and the result is displayed.

    PROGRAM:

    Welcome page .html

    Connecting Database with JavaBean




    Author Id:
    URL:
    Driver Name:



    GET AUTHORNAME.JSP: <%-- Import the package --%> <%@ page import ="java.util.*" %> <%@ page import = "test.FindAuthor" %> JSP and JavaBean

    <%-- Create an instance of FindAuthor class --%>

    <jsp:useBean id="FA" scope="application" class="test.FindAuthor" /> <%-- Set the value of various attribute, such as authorId, url, and driverName --%>

    <jsp:setProperty name="FA" property="*" />



    <%-- The details about the author, <jsp:getProperty name="FA" property="authorName"/> is:
    --%> <% /* Create an instance of type of Vector and invoking the function getResult() to return the result set*/ Vector v = (Vector)FA.getResult(); Enumeration enum = v.elements(); /* Prints the elements in the vector variable */ while(enum.hasMoreElements()) { out.println("Author Name:"+enum.nextElement()); %>
    <% out.println("Address:"+enum.nextElement()); %>
    <% out.println("City:"+enum.nextElement()); %>
    <% out.println("State:"+enum.nextElement()); %>
    <% out.println("ZIP:"+enum.nextElement()); } %> OUTPUT:

    RESULT: Thus the JSP program has been executed successfully and the result is displayed.

    PROGRAM:

    <script type="text/javascript"> var d= new Date(); var weekday= new Array("Sunday","Monday","Tuesday","Wednesday", "thursday","friday","saturday"); var monthname=new Array("jan","feb","mar","apr","may","jun", "jul","aug","sep","oct","nov","dec"); document.write(weekday[d.getDay()]+" "); document.write(monthname[d.getMonth()]+" "); document.write(d.getFullYear());

    OUTPUT:

    RESULT: Thus the program has been successfully executed and the result is displayed.

Related Documents

Wt Record
May 2020 7
Wt
May 2020 5
Wt
June 2020 8
Classification Wt
May 2020 12
Wt Chart
November 2019 11
Parking Agreement Wt&c
October 2019 15