Program#1: Explain The Steps To Create A Database Using Ms-Access
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.
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.
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
Output:
ASET
Page 5
Output:
ASET
Page 6
Output:
ASET
Page 7
ASET
Page 8
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
ASET
Page 11
Output:
ASET
Page 12
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
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
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
<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
ASET
Page 20
ASET
Page 21
ASET
Page 22
Output:
ASET
Page 23
ASET
Page 24
Output:
ASET
Page 25
{ 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
ASET
Page 28
Output:
ASET
Page 29
{ 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
ASET
Page 32
Output:
ASET
Page 33
} catch(Exception e) { } } }
ASET
Page 35
Output:
ASET
Page 36
<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
Hyperlink (Container tag) Ordered List (Container tag) Unordered List (Container tag) Table (Container tag)
</body> <html>
ASET
Page 40
Output:
ASET
Page 41
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
ASET
Page 45
ASET
Page 46
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);
ASET
Page 48
//w+=1;
ASET
Page 49
} function a9(digit)
ASET
Page 50
</script>
</head>
<body>
<form name="calculator">
<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 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