Вы находитесь на странице: 1из 56

Program#1 Explain the steps to create a database using Ms-Access.

Double click on the Access 2007 icon on the Windows desktop (see right), or click-on the Start button in the lower left corner of the screen, then click-on Programs, and then click-on Microsoft Access 2007. The Getting Started with Microsoft Office Access screen will appear (image below).

For previous Access users: The above menu screen is new in Access 2007. Take a few minutes to peruse this screen. You will notice that (on the top left of the screen) that the old Access Templates (already created databases) are still available.

As we move through this tutorial, many features of old Access will be familiar to you. Well begin with a Blank Database and increase our database knowledge with each step.

ASET

Page 1

Look at the center of your Access screen. You will see Getting Started with Microsoft Office Access. Below the title you will see a Blank Database button.

Click the Blank Database button.

As soon as you click the Blank Database button, the right side of your Access screen will change and look like the image on the left. Saving your work One of the unique things about Access database is that it requires you to save your database as soon as you enter the program. You can save your work on a floppy diskette in the A: Drive, on a USB key/Flash Drive or on your C: Hard Disk, or in some other drive. Please save to one of these areas and substitute your Drive in the instructions.

To choose the Drive, on which you will save your Access database, click the small folder to the right of File Name: A New File Database menu screen similar to the one below will appear when you click the folder.

ASET

Page 2

In the upper left corner of the File New Database menu screen that appears, you will see a Save in: area (see upper left arrow above). Click-on the small down arrow on the right and it will show you the various disk drives available on which you can save (see right upper arrow above). Point to the drive on which you want to save your database, and click-on it. If you choose the 3 Floppy (A:), make sure you have a formatted disk in the A drive. If you choose the C: drive, choose the folder in which you want to save by double clicking on the folder. Your selection should now appear in the Save in: area Next click-in the area to the right of File Name:. Delete any text that is entered in the area and then type-in the word PERSON as shown at the bottom of the above image (see lower left arrow). Now click-on the OK button or tap the Enter key (see lower right arrow on last page). You will now return to the Getting Started with Microsoft Office Access screen. On the right side of the screen you will see your database File Name and below it, the Drive on which you will create Creating a Table When you click the Create button your Access 2007 screen will change to the image below. This is the new look in 2007 Office. You will now see Tabs and Ribbons that automatically appear for the area in Access on which youre working. Instead of a Menu Bar and drop down selections, youll now see these new features. Tabs

ASET

Page 3

Ribbon

Groups
When we clicked the Create button Access assumed we desired to create within our Person database another database which is called a Table. Youll notice that at the top of the above image that the Table Tools and Datasheet Tabs appeared to assist you. The Ribbon below these Tabs is composed of Groups of selections youll use to assist you as you create your Table. Well be working with these Tabs/Ribbons throughout this tutorial. In the lower portion of the above image youll see selecti ons that indicate we are creating a new Table. On the left of the Table Tools-Datasheet Tab/Ribbon youll see a View button. Click the View button.

When you click the View the left will appear. Since design a new Table, well selection.

button the image on we want to create or click the Design View

A Save As menu screen will appear similar to the image on the right. Type personnel in the Table Name: area and then click the OK button. Your Access 2007 screen will now change again to the image below.

ASET

Page 4

Program#2 WAP in JSP to print Hello and I 5 times.


<html> <body> <b>Hello in HTML</b><br> <%! int i; %> <% for(i=1;i<=5;i++) { %> value of I = <%=i %> <br> <% } %> </body> </html>

Output:

ASET

Page 5

Program#3 WAP in JSP to use CheckBox.


<html> <body> <form action = "check_action.jsp" method = post> Hobbies : <br> <input type = checkbox name = ch1 value = "A">a<br> <input type = checkbox name = ch1 value = "B">b<br> <input type = checkbox name = ch1 value = "C">c<br> <input type = checkbox name = ch1 value = "D">d<br> <input type = checkbox name = ch1 value = "E">e<br> <input type = submit value = "Submit The Form"> </form> </body> </html>

Output:

ASET

Page 6

Program#4 WAP in JSP to Display Action of CheckBox.


<html> <body> <% String s[] = request.getParameterValues("ch1"); for(int i=0;i<s.length;i++) { out.println(s[i]+"<br>"); } %> </body> </html>

Output:

ASET

Page 7

Program#5 WAP in JSP to show different types of comments used.


<html> <body> Comments Are : <br> <%! int x = 10; %> Value of X = <%=x %><br> <!-- Value of X = <%=x %><br>--> <%-- Value of X = <%=x %> --%> <br> </body> </html> Output:

ASET

Page 8

Program#6 WAP in JSP to make an entry form.


<html> <body> <form action = entry_action.jsp method = post> Roll No : <input type = text name = "T1"><br> Enter Name : <input type = text name = "T2"><br> Contact No : <input type = text name = "T3"><br> <input type = submit value = "Submit The Form"> </form> </body> </html>

Output:

ASET

Page 9

Program#7 WAP in JSP to run insert query and enter values in database.
<html> <body> <%@ page import = "java.sql.*" %> <%! int id,ph; String sname; %> <% id = Integer.parseInt(request.getParameter("T1")); sname = request.getParameter("T2"); ph = Integer.parseInt(request.getParameter("T3")); //out.println(id+" , "+sname+" , "+ph); try { Connection con; PreparedStatement ps; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:jsp_dsn"); ps = con.prepareStatement("insert into student values("+id+",'"+sname+"',"+ph+")"); ps.executeUpdate(); ps.close(); con.close(); } catch(Exception e) { } %>

ASET

Page 10

<%@ include file = "entry.htm" %> </body> </html>

ASET

Page 11

Output:

ASET

Page 12

Program#8 WAP in JSP to Create HOME PAGE.


<html> <body> <center> <font color = red size = 10>Home Page</font><br> </center> <a href = entry.htm>New Entry</a><br> <a href = display.jsp>Display</a><br> <a href = delete.jsp>Delete</a><br> <a href = update.jsp>Update</a><br> </body> </html> Output:

ASET

Page 13

Program#9 WAP in JSP to run Display query and print values from database.
<html> <body> <%@ page import = "java.sql.*" %> <% try { out.println("<table border = 3>"); out.println("<tr>"); out.println("<th>Roll No</th><th>Name</th><th>Contact No</th>"); out.println("</tr>"); Connection con; Statement st; ResultSet rs; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:jsp_dsn"); st = con.createStatement(); rs = st.executeQuery("select * from student"); while(rs.next()) { out.println("<tr>"); out.println("<td>"+rs.getString("id")+"</td><td>"+rs.getString("sname")+"</td><td>"+rs.getString(" phno")+"</td>"); out.println("</tr>"); } st.close(); rs.close(); con.close(); out.println("</table>"); ASET Page 14

} catch(Exception e) { } %> </body> </html>

ASET

Page 15

Program#10 WAP in JSP to run delete query and delete same values from database.
<html> <body> <form action = "delete_action.jsp" method = post> <%@ page import = "java.sql.*" %> <% try { out.println("<table border = 3>"); out.println("<tr>"); out.println("<th>Roll No</th><th>Name</th><th>Contact No</th>"); out.println("</tr>"); Connection con; Statement st; ResultSet rs; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:jsp_dsn"); st = con.createStatement(); rs = st.executeQuery("select * from student"); while(rs.next()) { int i = Integer.parseInt(rs.getString("id")); out.println("<tr>"); out.println("<td><input type = radio name = r1 value "+i+">"+i+"</td><td>"+rs.getString("sname")+"</td><td>"+rs.getString("phno")+"</td>"); out.println("</tr>"); } st.close(); rs.close(); ASET Page 16 =

con.close(); out.println("</table>"); } catch(Exception e) { } %> <input type = submit value = "Delete"> </form> </body> </html>

ASET

Page 17

Program#11 WAP in JSP to show the action page of delete query.


<html> <body> <%@ page import = "java.sql.*" %> <%! int rno; %> <% try { rno = Integer.parseInt(request.getParameter("r1")); Connection con; PreparedStatement ps;

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:jsp_dsn"); ps = con.prepareStatement("delete from student where id = "+rno); ps.executeUpdate(); con.close(); ps.close(); } catch(Exception e) { } %> <%@ include file = "delete.jsp" %> </body> </html>

ASET

Page 18

Program#12 WAP in JSP to use combo box.

<html> <body> <%! int i; %> <% out.println("<select>"); for(i=1;i<=5;i++) { out.println("<option>"+i+"</option>"); } out.println("</select>"); %> </body> </html> Output;

ASET

Page 19

Program#13 WAP in JSP to use radio buttons.


<html> <body> <form action = "radio_action.jsp" method = post> Select Category<br> <input type = radio name = r1 value = "General">Gen<br> <input type = radio name = r1 value = "sc">SC<br> <input type = radio name = r1 value = "st">ST<br> <input type = radio name = r1 value = "obc">OBC<br> <input type = submit value = "SUBMIT"> </form> </body> </html> Output:

ASET

Page 20

Program#14 WAP in JSP to show action of radio button.


<html> <body> <%! String s; %> <% s = request.getParameter("r1"); out.println("VALUE = "+s); %> </body> </html> Output:

ASET

Page 21

Program#15 WAP in java to run Select query.


import java.sql.*; public class set { public static void main(String s[]) { try { Connection con; Statement st; ResultSet rs; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:Sugandhita"); st=con.createStatement(); rs=st.executeQuery("select * from Info"); while(rs.next()) { System.out.println(rs.getString("Roll")+rs.getString("name")); } con.close(); st.close(); rs.close(); } catch(Exception e) { } } }

ASET

Page 22

Output:

ASET

Page 23

Program#16 WAP in java to run Insert query.


import java.sql.*; public class insert { public static void main(String s[]) { try { Connection con; PreparedStatement ps; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:Sugandhita");

ps=con.prepareStatement("insert into Info values(3,'pranay','pathankort',99999)"); ps.executeUpdate(); con.close(); ps.close(); } catch(Exception e) { } } }

ASET

Page 24

Output:

ASET

Page 25

Program#17 WAP in java to run Insert query using DataInputStream.


import java.sql.*; import java.io.*; public class insert1

{ public static void main(String s[]) { try { DataInputStream ob=new DataInputStream(System.in); String name,Address; int Roll,Phone_no; System.out.println("enter rollno."); Roll=Integer.parseInt(ob.readLine()); System.out.println("enter your name"); name=ob.readLine(); System.out.println("enter your address"); Address=ob.readLine(); System.out.println("enter your phone no."); Phone_no=Integer.parseInt(ob.readLine()); Connection con; PreparedStatement ps; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:Sugandhita");ps=con.prepareStatement("inser t into Info values("+Roll+",'"+name+"','"+Address+"',"+Phone_no+")"); ps.executeUpdate(); con.close(); ps.close(); ASET Page 26

} catch(Exception e) { } } } Output:

ASET

Page 27

Program#18 WAP in java to run Delete query.


import java.sql.*; public class delete { public static void main(String s[]) { try { Connection con; PreparedStatement ps; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:Sugandhita"); ps=con.prepareStatement("delete from Info where Roll=3"); ps.executeUpdate(); con.close(); ps.close(); } catch(Exception e) { } } }

ASET

Page 28

Output:

ASET

Page 29

Program#19 WAP in java to run Delete query using DataInputStream.


import java.sql.*; import java.io.*; public class delete

{ public static void main(String s[]) { try { DataInputStream ob=new DataInputStream(System.in); String name,Address; int Roll,Phone_no; System.out.println("enter rollno. you want to delete"); Roll=Integer.parseInt(ob.readLine()); Connection con; PreparedStatement ps; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:Sugandhita"); ps=con.prepareStatement("delete from Info where Roll="+Roll+""); ps.executeUpdate(); con.close(); ps.close(); } catch(Exception e) { } } }

ASET

Page 30

Output:

ASET

Page 31

Program#20 WAP in java to run Update query.


import java.sql.*; public class update { public static void main(String s[]) { try { Connection con; PreparedStatement ps; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:Sugandhita"); ps=con.prepareStatement("update Info SET name=pranay where Roll=3); ps.executeUpdate(); con.close(); ps.close(); } catch(Exception e) { } } }

ASET

Page 32

Output:

ASET

Page 33

Program#21 WAP in java to run Update query using DataInputStream.


import java.sql.*; import java.io.*; public class update { public static void main(String s[]) { try { DataInputStream ob=new DataInputStream(System.in); String name,Address; int Roll,Phone_no; System.out.println("enter rollno. you want to update"); Roll=Integer.parseInt(ob.readLine()); System.out.println("enter name"); name=ob.readLine(); System.out.println("enter address"); Address=ob.readLine(); System.out.println("enter phone no."); Phone_no=Integer.parseInt(ob.readLine()); Connection con; PreparedStatement ps; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:Sugandhita"); ps=con.prepareStatement("update Info set name='"+name+"', Address='"+Address+"',Phone_no="+Phone_no+""+"where Roll="+Roll+""); ps.executeUpdate(); con.close(); ps.close(); ASET Page 34

} catch(Exception e) { } } }

ASET

Page 35

Output:

ASET

Page 36

Program#22 Write HTML code to display following tags


1. Title tag (Container tag) 2. Body tag (Container tag) 3. Marquee tag (Container tag) 4. Bold tag (Container tag) 5. Italics tag (Container tag) 6. Strike tag (Container tag) 7. Underline tag (Container tag) 8. Horizontal Rule (Empty tag) 9. Break line (Empty tag) 10. Pre tag (Container tag) 11. Font tag (Container tag)

<html> <title>HomePage</title> <body vlink=green alink=cyan> <hr> <marquee direction = up> <font color=blue face="Times New Roman" size=12 align=right> <sub>W</sub>e<b>l</b>com<sup>e</sup></font><br> this <strike>is</strike> <u>my</u> <i>home</i> page<br> </marquee> <hr> <pre>Hello kushagra </pre> </body> </html>

ASET

Page 37

Output:

ASET

Page 38

Program#23 Write HTML code to display following tags


1. 2. 3. 4.
<html> <body> <b>b'day plan</b> <ol type=1> <li>kushagra</li> <li>himanshu</li> <ul type square><li>bharat</li> <li>pranay</li></ul> <li>mayank</li> <ol type=a><li>prakhar</li> <li>shashank</li></ol> <li>archit</li> <li>shauryan</li> <li>satyam</li> </ol> <center>Hyperlink</center><br> <a href="D:\Java\Apache Ethical</a> <center>Table</center> <table border=4 Stream\IMG_0064.jpg"><tr> background="C:\Users\Nonu\Pictures\PhotoStream\MyPhoto Software Foundation\Tomcat 7.0\webapps\Nonu\Homepage.htm">

Hyperlink (Container tag) Ordered List (Container tag) Unordered List (Container tag) Table (Container tag)

<th>roll.no</th><th>name</th><th>address</th> </tr> <tr><td>1</td><td>sugandhita</td><td>delhi</td></tr> </table> ASET Page 39

</body> <html>

ASET

Page 40

Output:

ASET

Page 41

Program#24 Write HTML code to explain FORM tag.


<html> <body> <form> Name:<input type = text name = t1 maxlenght = 10><br> Password:<input type = password name = p1 maxlength = 10><br> Hobbies : <br> <input type = checkbox name = ch1 value = "A">Music<br> <input type = checkbox name = ch1 value = "B">ance<br> <input type = checkbox name = ch1 value = "C">Reading<br> <input type = checkbox name = ch1 value = "D">Listening<br> <input type = checkbox name = ch1 value = "E">Watching Movies<br> Gender<br> <input type = radio name = r1 value = "Male">Male<br> <input type = radio name = r1 value = "Female">Female<br> Select Category<br> <input type = radio name = r1 value = "General">Gen<br> <input type = radio name = r1 value = "sc">SC<br> <input type = radio name = r1 value = "st">ST<br> <input type = radio name = r1 value = "obc">OBC<br> Country: <select> <option>USA</option> <option>Canada</option> <option>Australia</option> <option>Africa</option> <option>India</option> </select>

ASET

Page 42

<br>Comments: <textarea cols = 10 row = 10></textarea><br> <input type = submit value = "Submit the Form" name = b1><br> </form> </body> <html>

ASET

Page 43

Output:

ASET

Page 44

Program#25 Write JavaScript to display Body part and Header part.


<html> <head> <script language = "JavaScript"> alert("header part") </script> <body> <script language = "JavaScript"> alert("body part") </script> </body> </Head> </html> Output:

ASET

Page 45

Program#26 Write HTML code to explain concept of frames.


<html> <body> <frameset rows=30%,70%> <frame src=abc.htm name=f1> <frameset cols=30%,70%> <frame src=aa.htm name=f2> <frame src="" name=f3> </frameset> </body> </html> Output:

ASET

Page 46

Program#27 Write a JavaScript to make a calculator.


<html> <head> <script language="javascript" type="text/javascript"> w="";a="";z="" function multiply(){ a=Number(document.calculator.number1.value); z=3; c=a*b; document.calculator.total.value=c; }

function addition(){ b=Number(document.calculator.number1.value); z=1; w=""; document.calculator.number1.value=""; } function equalto(){ if(z==1) { a=Number(document.calculator.number1.value);

c=a+b; w=""; document.calculator.number1.value=c; c=0; } ASET Page 47

function subtraction(){ a=Number(document.calculator.number1.value); z=2; c=a-b; document.calculator.total.value=c; }

function division(){ a=Number(document.calculator.number1.value); z=4 document.calculator.total.value=c; }

function modulus(){ a=Number(document.calculator.number1.value); z=5

function a0(digit) {w=w+""+digit; document.calculator.number1.value=w;

ASET

Page 48

//w+=1;

} function a1(digit) {w=w+""+digit; document.calculator.number1.value=w; //w+=1;

} function a2(digit) {w=w+""+digit; document.calculator.number1.value=w; //w+=1;

} function a3(digit) {w=w+""+digit; document.calculator.number1.value=w; //w+=1;

} function a4(digit) {w=w+""+digit; document.calculator.number1.value=w; //w+=1;

ASET

Page 49

} function a5(digit) {w=w+""+digit; document.calculator.number1.value=w; //w+=1;

} function a6(digit) {w=w+""+digit; document.calculator.number1.value=w; //w+=1;

} function a7(digit) {w=w+""+digit; document.calculator.number1.value=w; //w+=1;

} function a8(digit) {w=w+""+digit; document.calculator.number1.value=w; //w+=1;

} function a9(digit)

ASET

Page 50

{w=w+""+digit; document.calculator.number1.value=w; //w+=1;}

</script>

</head>

<body>

<form name="calculator">

Number 1: <input type="text" name="number1">

<input type="button" value="0" onclick=a0(0)> <input type="button" value="1" onclick=a1(1)> <input type="button" value="2" onclick=a2(2)> <input type="button" value="3" onclick=a3(3)> <input type="button" value="4" onclick=a4(4)> <input type="button" value="5" onclick=a5(5)> <input type="button" value="6" onclick=a6(6)> <input type="button" value="7" onclick=a7(7)> <input type="button" value="8" onclick=a8(8)> <input type="button" value="9" onclick=a9(9)> <input type="button" value="ADD" onclick="javascript:addition();"> <input type="button" value="SUB" onclick="javascript:subtraction();">

ASET

Page 51

<input type="button" value="MUL" onclick="javascript:multiply();"> <input type="button" value="DIV" onclick="javascript:division();"> <input type="button" value="MOD" onclick="javascript:modulus();"> <input type="button" value="Equals" onclick="javascript:equalto();"> </form> </body> </html>

ASET

Page 52

Program#28 Write a java program to use Remote method invocation (server side).
import java.rmi.*; import java.rmi.registry.*; import java.rmi.server.*;

public class RMIServer extends UnicastRemoteObject implements MethodImpl {

public RMIServer() throws RemoteException { System.out.print("server is intantiated"); }

public int getSquare(int x) { return x*x; }

public static void main(String[] args) { try { RMIServer server=new RMIServer(); Naming.rebind("sqr",server); } catch(Exception e) { }

ASET

Page 53

} } Output:

ASET

Page 54

Program#29 Write a java program to use Remote method invocation (client side).
import java.rmi.*; import java.rmi.registry.*; public class RMIClient { public static void main(String s[]) { try { MethodImpl ob=(MethodImpl)Naming.lookup("rmi://10.2.22.116/sqr"); int i=ob.getSquare(10); System.out.println("Square of the number="+i); } catch(Exception e) { } } } import java.rmi.*; public interface MethodImpl extends Remote { public int getSquare(int x)throws RemoteException; }

ASET

Page 55

Output:

ASET

Page 56

Вам также может понравиться