Pages

Wednesday, May 19, 2010

Padam Shri Gopal das neeraj - CHHUP-2 ASHRU BAHANE WALO...

Ye kavita humein prerit karti hai gham ke andheron se bahar nikalne ki ....
Aur is kathor yathaarth ko samajhne kee, ki sangi-sathi, sapne sab choot bhi jayein to ye jeewan phir bhi chalta rehta hai bina ruke bina thame…
----------------------------------------
Chip Chip ashru bahaane waalon (ashru-tears)
Moti vyarth lutane waalon ! (vyarth –without any purpose)
Kuch sapnon ke mar jane se jeevan nahin mara karta hai

Sapnaa kya hai ? Nayan sez par,
Soya hua aankh ka paani
Aur tootna hai uska jyon
Jage kachchi neend jawani
Geelee umar banaane walon! Doobe bina nahaane waalon
Kuch pani ke bah jane se saawan nahin mara karta hai

Mala bikhar gayi to kya hai
Khud hi hal ho gayi samasyaa (samasya-problem)
Aansoo gar neelaam huye to
Samjho poori huyi tapasyaa
Roothe divas manaane walon! Phati kameez silaane waalon! (divas-day)
Kuch deepon ke bujh jaane se aangan nahin mara karta hai

Khota kuch bhi nahin yahan par
Kewal zild badaltee pothee (pothee –book)
Jaise raat utaar chandani
Pehne subah dhoop ki dhoti
Vastra badal kar aane waalon ! Chaal badalkar jaane waalon! (vastra –cloth)
Chand Khilounon ke khone se bachpan nahin maraa karta hai

Laakhon baar gagriyaan phooteen
Shikan na aayi panghat par
Lakhon baar kishtiyaan doobeen
Chahal-pehal wo hi hai tat par (tat-beach)
Tam ki umra badhaane waalon! Lau ki aayu ghatane waalon ! (tam-darkness)
Laakh kare patjhad koshish par upvan nahin maraa kartaa hai (upvan-garden)

Loot liya maali ne upvan
Luti na lekin gandh phool ki
Toofaanon tak ne cheda par
Khidki band na huyi dhool kee
Nafrat gale lagaane waalon! Sab par dhool udaane waalon
Kuch mukhdon ki naaraazee se darpan nahin maraa karta hai

Chip Chip ashru bahaane waalon (ashru-tears)
Moti vyarth lutane waalon ! (vyarth –without any purpose)
Kuch sapnon ke mar jane se jeevan nahin mara karta hai


-Padam Shri Gopal Das 'Neeraj'

Saturday, May 1, 2010

Object Oriented Systems Sample Paper B.Tech-CS, UPTU





Object Oriented Systems Important Questions, MCA-412, Part 1


Q1. What is the java Bean? What are their advantages? What are various introspection Mechanism to inter information of a Bean? Explain with a suitable example.

Q2. Explain the following with the help of suitable example:
  1. Dynamic BillBoard Applet
  2. Lavatron Applet
  3. JDBC
  4. Java Swing
  5. Scrabblets

Q3. What is difference between AWT and Swing?

Q4. Explain any two methods available in servlet package.

Q5.  What is a java Servlet? Explain briefly the life cycle of a servlet.What are the basic steps for creating a Servlet ?

Q6. Write a java Program to create a thread that displays odd numbers starting from 1 to 100.

Q7. Write a java program to sort an array of string entered through the keyboard.

Q8. What is java Bean? What are the various steps which are needed to create a new Bean?

Q9. What do you understand by inter Thread Communication? Explain it.

Q10. Write a program to print factorial numbers.

Q11. Describe JDBC Architecture.

Q12.  Discuss the various feature of the lavatron applet and srabblet.

Q13. Discuss any six methods available in Dynamic BillBoard applet.

Q14. Explain the procedure of JDBC connectivity in java with windows database. A data of 100 students having following fields in the records is to be imported in java.
Record Structure:
        
        Name : Character Array of 100
        Address: Character Array of 200
        Roll Number : integer
        Amount Due: Float
        Marks: Integer
        Grade: Single character having values a, b, c, d, or e.
        Write a java program to import these records from windows and send to output text file.



Monday, April 19, 2010

Fetch data from MS Access using java

Database

JDBCExample


import  java.sql.*;

public class JDBCExample
{

private String url,user,pwd;
private Connection conn;
private Statement stmt;
private PreparedStatement pstmt;
private ResultSet rs;

public JDBCExample()
{
}

public void testDatabase()
{
int i=0;
String sql;

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(Exception sqe)
{
System.out.println("Error loading driver");
}
url="jdbc:odbc:emp";



pwd ="";
user="";

try
{
conn=DriverManager.getConnection(url,user,pwd);
}
catch(SQLException sqe)
{
System.out.println("Error getting connection to database");
}

try
{
stmt=conn.createStatement();
}
catch(SQLException sqee)
{
System.out.println("Error creating statement");
}

try
{
rs=stmt.executeQuery("select * from emp");
}
catch(SQLException qexe)
{
System.out.println("Error executing query");
}





/*try
{
while(rs.next())
{
int code=rs.getInt(1);
System.out.println("code="+code);
}
}

catch(SQLException e)
{
System.out.println("error to trversing");
}*/

try
{
while(rs.next())
{
String name=rs.getString(1);
int rollno=rs.getInt(2);
String add=rs.getString(3);
int phoneno=rs.getInt(4);
System.out.println("name="+name);
System.out.println("rollno="+rollno);
System.out.println("add="+add);
System.out.println("phoneno="+phoneno);
System.out.println("      ");

}


}

catch(SQLException es)
{
System.out.println("error to traversing");
}


try
{
rs.close();
conn.close();
}
catch(SQLException sqxe)
{
System.out.println("Error closing result set or connection");
}
}

public static void main(String args[])
{
JDBCExample jdbcex=new JDBCExample();
jdbcex.testDatabase();

}
}

Friday, April 16, 2010

Insert Data into Access Database using JSP

Project Tree

Database


registration.jsp

<%--
    Document   : display
    Created on : 13 Apr, 2010, 9:54:48 AM
    Author     : Bhasker
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>registration</title>
    </head>
    <body>
        <h1>registration form</h1>

        <form name="registration1" action="display.jsp" method="POST">
        <table border="1">

            <thead>
                <tr>
                    <th>enter information</th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>name</td>
                    <td><input type="text" name="n1" value="" size="30" /></td>
                </tr>
                <tr>
                    <td>city</td>
                    <td><input type="text" name="c1" value="" size="30" /></td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="submit" value="submit" name="b1" /></td>
                </tr>
            </tbody>
        </table>

</form>


    </body>

</html>


display.jsp

<%-- 
    Document   : display
    Created on : 14 Apr, 2010, 2:38:06 PM
    Author     : Bhasker
--%>
<%@page import ="java.sql.*"%>
<%@page import =" java.util.*"%>
<%@page import =" java. io.*"%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>registration record!</h1>


        <%
              try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
           Connection con=DriverManager.getConnection("jdbc:odbc:reg");
           Statement st=con.createStatement();
           PreparedStatement pst=con.prepareStatement("insert into registration(name,city) values(?, ?)");
           pst.clearParameters();
           
           pst.setString(1,request.getParameter("n1"));
           pst.setString(2,request.getParameter("c1") );
         int i=  pst.executeUpdate();
         if(i>0)
             {
         out.println("Record Saved");

         ResultSet rs=st.executeQuery("Select * from registration");
         out.print("<br/>");

         out.print("<table border=4>");
           while(rs.next())
           {
               out.print("<tr bgcolor=pink>");
               out.print("<td>");
           out.print(rs.getString(1));
           out.print("</td>");
           out.print("<td>");
           out.print(rs.getString(2));
           out.print("</td>");
out.print("</tr>");

           }
         out.print("</table>");
         }
         else
             {out.println("Record Not Saved");}
           
      

        }
        catch(Exception e)
        {}
        finally {
            out.close();
        }

        %>

    </body>

</html>

Thursday, April 15, 2010

WAP to demonstrate database connectivity jsp with MS Access with the help of servlet.

Project Tree

index.jsp



<%-- 
    Document   : index
    Created on : Mar 23, 2010, 11:50:05 AM
    Author     : Administrator
--%>


<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">


<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>


        <form action="NewServlet">
            <input type="submit" value="Show Record" />
        </form>
    </body>
</html>

NewServlet.java

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;
/**
 *
 * @author Administrator
 */
public class NewServlet extends HttpServlet {
   
    /** 
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
           Connection con=DriverManager.getConnection("jdbc:odbc:test");
           Statement st=con.createStatement();
           ResultSet rs=st.executeQuery("select * from employee");
           while(rs.next())
           {
           out.print(rs.getString(1));
           out.print(rs.getString(2)); 
           out.print(rs.getString(3));
         
           }

            /* TODO output your page here
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet NewServlet</title>");  
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Servlet NewServlet at " + request.getContextPath () + "</h1>");
            out.println("</body>");
            out.println("</html>");
            */
        }
        catch(Exception ee)
        {}
        finally {
            out.close();
        }
    } 

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** 
     * Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    } 

    /** 
     * Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }

    /** 
     * Returns a short description of the servlet.
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}

WAP to demonstrate database connectivity jsp with MS Access with the help of beans.

Project file Tree 



DataBase





index.java



<%@page language="Java" import="java.sql.*" %>
 <jsp:useBean id="db" scope="request" class="SQLBean.DbBean" />
 <jsp:setProperty name="db" property="*" />
  <%!
          ResultSet rs = null ;

         int i;
%>


<HTML>
<HEAD><TITLE>DataBase Search</TITLE></HEAD>
<BODY>
<h2> Results from </h2>
<hr>
<br><br>
<table border="1">

<%
   db.connect();

try {
          rs = db.execSQL("select * from EMPLOYEE");
          i = db.updateSQL("UPDATE employee set empid = 'e005' where empname='ravi'");
        
        }catch(SQLException e) {
              throw new ServletException("Your query is not working", e);      
              }

         %>
<tr>
    <th>Emp ID</th>
    <th>NAME</th>
    <th>ADDRESS</th>
</tr>
<%      
      while(rs.next()) {
%>
<tr>

<td><%= rs.getString("empid") %></td>
<td><%= rs.getString("empname") %></td>
<td><%= rs.getString("empadd") %></td>

</tr>


<%
}
%>
<%  db.close();

%>

</table>

</body>

<HTML>




DBBean.java


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package SQLBean;
import java.sql.*;
//import java.io.*;
/**
 *
 * @author Administrator
 */
public class DbBean {
String dbURL = "jdbc:odbc:test";
  String dbDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
  private Connection dbCon;

  public DbBean(){
       super();      
       }

  public boolean connect() throws ClassNotFoundException,SQLException{
          Class.forName(dbDriver);
          dbCon = DriverManager.getConnection(dbURL);
          return true;
        }
  public void close() throws SQLException{
        dbCon.close();
       }

  public ResultSet execSQL(String sql) throws SQLException{

                    Statement s = dbCon.createStatement();
                    ResultSet r = s.executeQuery(sql);
                    return (r == null) ? null : r;
                    }

  public int updateSQL(String sql) throws SQLException{                  
                   Statement s = dbCon.createStatement();
                   int r = s.executeUpdate(sql);
                   return (r == 0) ? 0 : r;
                }
}






Followers