Simple Chat Application Using Applet




1. Client.java
package chatterapi;
/*
 @navindra k. jha
 */

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;

public class Client extends Applet implements ActionListener, Runnable
{

        Image Icon = Toolkit.getDefaultToolkit().getImage("D:/Example/emperian/jsf/ChatterAPI/src/chatterapi/hi.gif") ;

Hit Counter for a Web site, time of hitting and no. of current users



Many times you would be interested in knowing total number of hits of your site, time of hitting, and number of users currently using your site.

This post is about creating a hit counter that counts number of site visit. There are various ways for creating hit counter in servlet but here we have implemented hit counter using ServletContextListener. ServletContextListener is a listener interface that gets notified when the context is initialized and destroyed.

index.html
<body>
        <form name="loginForm" method="get" action="LoginServlet">
            Username<input type="text" name="txtname" size="20"><br>
            Password<input type="password" name="txtpass" size="20"><br>
            <input type="submit" value="Login">
        </form>
    </body>

How to export data from database to excel sheet




It is very simple to import data from database to Excel, follow below steps

I have “student” table in “stu” database and book1.xlsx excel file in x drive.
Student table has three field name, roll, and marks

Before importing data you must have an Excel file in which data is imported and specify field name in cell like NAME, ROLL, and MARKS in different cells.

NAME
ROLL
MARKS







I am using MySql database.

Abstraction and Encapsulation



In an object-oriented programming language Encapsulation and Abstraction are very confusing words, everyone feels confused to understand.
Here I give in my own style of explanation.
Abstraction:
 The essential characteristics of an entity that distinguishes it from all other kinds of entities.

In other word,

“Only the characteristics of the system that are essential to the problem being studied are modelled; minor or irrelevant details are ignored.”

 It defines a boundary relative to the perspective of the viewer. It allows us to manage complexity by concentrating on the essential characteristics of an entity.

ARE YOU KNOW ANSWER OF THIS QUESTION?


1. How to get last inserted id in hibernate?
2. How to insert date in database?
3. You can override static method in java?
4. Which one is better struts2 or spring?
5. How many ways to create object in java?
6. Why java use both compiler and interpreter?
7. Why and where uses throw keyword?
8. When stack over follow error is occurred?
9. Difference between heap and stack memory, why not everything store in heap?
10. Difference between abstract factory and factory design pattern?

ANSWER:

DatabaseMetaData



The simple meaning of metadata is data about data. There are two metadata available in the JDBC API - ResultSetMetaData and DatabaseMetaData.

This interface provides method to find out information about the database product being used, Driver Information, Operation Supported by Database, Details of Table, Procedures, Sequence etc.

getMetaData() method of Connection interface is used to obtained the reference of database metadata object.

Commonly used methods:

ResultSetMetaData



The simple meaning of metadata is data about data. There are two metadata available in the JDBC API - ResultSetMetaData and DatabaseMetaData.

This interface provide method to find out information such as number of columns return in the result set , name and types of column their source table etc.

getMetaData() method of ResultSet Interface is used to obtained the reference of ResultSetMetaData.
public  ResultSetMetaData getMetaData();


Reflection API


Reflection API provide the facility find out the details of a class at execution time as well as facility to load a class, to create an instance of a class to invoke a constructor or method on a class object to get and set value of a field etc.
java.lang.reflect package provide classes of reflection API. Commonly use class of Reflection API
Method:
A Method provides information about, and access to, a single method on a class or interface. The reflected method may be a class method or an instance method (including an abstract method).
Field:
A Field provides information about, and dynamic access to, a single field of a class or an interface. The reflected field may be a class (static) field or an instance field.
Constructor:
Constructor provides information about and access to, a single constructor for a class.