Saturday, 25 November 2017

How to Create SEQUENCE


CREATE SEQUENCE  SNO_BSB

MINVALUE 0 MAXVALUE 9999

INCREMENT BY 1

START WITH 1

CACHE 20

NOORDER

 CYCLE ;

This will create sequence with minvalue of 0 and maxvalue of  9999 and this will get increment by one every time. It will start with 1 having cache value of 20 and there is noorder and cycle means it will get repeated once reached it;s limit.

How to create auto-increment trigger

create or replace TRIGGER SNO_INC_TRG

BEFORE INSERT ON Bsb
for each row

BEGIN
if inserting then
      if :NEW."SNO" is null then
         select SNO_SEQ.nextval into :NEW."SNO" from dual;
      end if;
   end if;
END;

This trigger is setting the next value of sequence into the column when the column named SNO has null value. This trigger gets executed before the insertion on table bsb and it will triggered every time the new row gets inserted.
                                               

Monday, 23 October 2017

How to Use Java Scanner Class


Program:


import java.util.*;
public class InputValues
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);

// Your name
System.out.print("What is your name? ");
String name = in.nextLine();

// Your age
System.out.print("How old are you? ");
int age = in.nextInt();
System.out.println("Hello, " + name + ". Your Age is "+ age +". Nice to Meet You");
}
}


Output:
Hello, bsb. Your Age is 23. Nice to Meet You

Saturday, 26 August 2017

Simple java ArrayList Program

Program:

package JavaCoders;
import java.util.*;
class ArrayList1
{
public static void main(String[] x)
{
ArrayList<String>ar=new ArrayList<String>();
ArrayList ar1=new ArrayList();
ArrayList ar2=new ArrayList();
ArrayList ar3=new ArrayList();


Monday, 3 July 2017

Program of interface in java

Program:

package JavaCoders;
/**
 *
 * @author Bsb
 */
interface abc
{
void m1();
}
interface bca
{
void m1();

Friday, 16 June 2017

How to Create a Basic Java Applet in NetBeans

Program:

package JavaCoders;
/**
 *
 * @author Bsb
 */
import java.applet.Applet;
import java.awt.Graphics;
public class applet_example extends Applet

{

Thursday, 15 June 2017

Program in java to check if two Strings are Anagram or not

Anagram program in java

Program:

package JavaCoders;
import java.util.Arrays;
public class Anagram
{
void ana(String s1,String s2)
{
String st1=s1.replaceAll("\\s", "");
String st2=s2.replaceAll("\\s", "");
boolean b=true;
if(st1.length()!=st2.length())

How to print sum of even numbers in java

Program:

package JavaCoders;
import java.util.Scanner;
/**
*
* @author Bsb
*/
class even_sum
{
public static void main(String[] args)
{
int i;
int sum=0;
System.out.println("Enter the number upto you want to sum:");
Scanner sc=new Scanner(System.in);
int num=sc.nextInt();
for(i=1;i<=num;i++)


Tuesday, 13 June 2017

How to reverse string in java

Program:

package JavaCoders;

import java.util.Scanner;
public class rev_string
{
public static void main(String[] args)
{
String str1="";
String str2="";
System.out.println("Enter the string to be reversed:\n");
Scanner scn=new Scanner(System.in);
str1=scn.next();
for(int i=str1.length()-1;i>=0;i--)
{
str2=str2+str1.charAt(i);
}
System.out.println("Reversed String is: "+str2);
}
}

OUTPUT:

How-to-reverse-string-in-java

You can also go to link that ellaborate it more:

Monday, 12 June 2017

Simple Program of Typecasting in java

Simple Program of Typecasting in java Program:

package JavaCoders;
class Conversion
{
public static void main(String[] args)
{
String x="20000";
int a=67;
short b;
long c;
float d;
double e;
char f;
String z;
b=(short)a;
c=a;
d=a;
e=a;
f=(char)a;

Tutorial of JSP AJAX

AJAX INTRODUCTION :

Ajax stands for Asynchronous JavaScript and XML. Basically Ajax is not a programming language but it is a technique for using JavaScript. Basic features of Ajax are:

1. You can download any file in the background process from the web server.
2. User can dynamically update any page without the waiting by the user.
3. Web pages can be easily updated without reloading the current page.
4. It can request date from the server after the page has been loaded.
5, It can receive data from the server after the page has been loaded.
6. It can send the data to the server at the background.
7. Ajax is a web browser technology independent of web server software.
8. To get the data from the server you don't even have to click the button, you can just move your mouse for the action.

XMLHttpRequest Object:
XMLHttpRequest is the object to get the data from the server, it can get the information from the server without reloading the page.

Creating XMLHttpRequest Object: Basically all the browsers have built-in XMLHttpRequest Object. The syntax for creating XMLHttpRequest Object is:

var h= new XMLHttpRequest();

Saturday, 3 June 2017

Java Program to display current date and time

Program to display current date and time in java:

Post By: Balwant Singh

package kuw_ord.test;
import java.util.*;
public class date
{
public static void main(String[] args)
{
Date bs=new Date();
System.out.println(bs.toString());

}

}

Wednesday, 17 May 2017

How Add Method Works In ArrayList In Java With The Help Of Example

An ArrayList is an object that is used to store a group of the other objects and allows us to do manipulation on these objects one by one. Java ArrayList class basically uses a dynamic array for storing the elements.
The basic features of Java ArrayList class are given below:
  1. Java ArrayList class can contain duplicate elements to store.
  2. Java ArrayList class maintains insertion order.
  3. In Java ArrayList class, the manipulation is slow because there is lot of shifting to be occurred if any element is removed from the array list from any index.Suppose there is an arraylist of 4 elements having indices 0,1,2,3. If we want to delete the element placed at the index no, 1, then there will be shifting of elements from down as all the remaining elements goes up covering all the indices, so this is the reason the manipulation in arraylist is slow. 
  4. Java ArrayList class is non synchronized.It mean that there can be case when there can be multiple threads that can work together to modify the list at same time.

Friday, 12 May 2017

Registration form using swings in java

Registration form in java:

In this tutorial you will learn how to make a registration form in java using swings. Swings basically are used to develop desktop based applications for the users. Swings helps in creating beautiful applications that are rich and good enough to represent. With the help of Swings you can easily create attractive desktop based applications. JFrame is a class which is a extended version of java.awt.Frame which support Swings component architecture.

Following are the constructors that can be used to create applications:

1 .JFrame():Constructs a new frame that is initially invisible to the user.

2 JFrame(String title):Creates a new, initially invisible Frame to the user with the specified given title.
3 JFrame(String title, GraphicsConfiguration gc): It will create a JFrame with the specified title and the specified or configured GraphicsConfiguration of a screen device or monitor.


Wednesday, 10 May 2017

Program to sum two dimensional array in java

Sum of two dimensional array:-

This program will explain how to add array which is two dimensional.You first have to know what is two dimensional array.

Two Dimensional Array- Two dimensional array those array which is consists of elements of 2-d type. Basically 2-d means rows and columns.2-d dimensional array. It's syntax can be declared as given below:

data_type array_name[size1][size2];

A way to initialize the two dimensional array at the time of declaration is given below:

int arr[4][3]={{1,2,3}, {2,3,4}, {3,4,5}, {4,5,6}};
Example to declare 2-d dimensional array is:

int m[][]=new int[4][6];

Tuesday, 9 May 2017

Creating Progress Bar Using JProgressBar

Creating Progress Bar Using JProgressBar:

In this tutorial you will learning how to create Progressbar using JProgressBar for java application that is basically swings application.

A progress bar is basically a widget(an application, or a component of an interface, that enables a user to perform a function or can help to access a service) that displays progress of a lengthy task, usually used for downloading a or transfer some files. For creating a progress bar in swings you have to use the JProgressBar class. With the help of JProgressBar, you can easily create vertical or horizontal progress bar according to your need. In addition to the JProgressBar class,it allows you to create another kind of progress bar which is known as indeterminate progress bar. The indeterminate progress bar is used to display progress with unknown progress or the progress cannot express by the percentage.Basically it does not explain about how the progress is remain in terms of percentage.

There are some constructors used to create ProgressBar. These are:

1. public JProgressBar()- It creates a Horizontal progress bar.
2. public JProgressBar(int orientation)- It helps in creating horizontal as well as vertical progress bar. You can also create progress bar in any orientation.
3. public JProgressBar(int minimum,int maximum)- It help in creating progress bar which is having minimum values and maximum values.

Saturday, 6 May 2017

Servlets Tutorial for Beginners

Introduction to SERVLETS:

  1. A servlet is a Java class that extends an application hosted on a web server.
  2. Servlet technology is used to create web application 
  3. Servlet Handles the HTTP request-response process.
  4. Often it thought of as an applet that runs on a server.
  5. Provides a component base architecture for web development, using the Java Platform
  6. Servlet technology is a technology which is robust and scalable only because of java language.
Java Servlets are basicallly the programs that run on a Web or Application server and act as a middle layer between a request coming from a Web browser or others HTTP clients and databases or applications on the HTTP servers.
With the help of Servlets, you can easily collect input from the users through web page forms, present records from the database or any another source, and can create dynamic web pages.


Friday, 5 May 2017

Hibernate Overview for Beginners

Hibernate Overview:

Hibernate is an Object-Relational Mapping(ORM) solution for JAVA. It is an open source framework created by Gavin King in 2001. It is a powerful, high performance Object-Relational Persistence and Query service for any Java Application.
Hibernate maps Java classes to database tables and from Java data types to SQL data types and relieves the developer lots of  programming tasks. Hibernate acts between traditional Java objects and database server to handle all the works in persisting those objects based on the appropriate O/R mechanisms and patterns.

Hibernate Advantages:
  1. Hibernate takes care of mapping Java classes to database tables using XML files and without writing any line of code.
  2.  Provides simple APIs for storing and retrieving the Java objects directly to and from database.
  3.  If there is change in the database or in any table, then you only need to change the XML file properties.
  4.  Abstracts away the unfamiliar SQL types and provides a way to work around familiar Java Objects.
  5.  Hibernate does not require an application server to operate on.
  6.  Manipulates Complex associations of objects of your database.
  7.  Minimizes database access with smart fetching strategies.
  8.  Provides simple querying of data.
  9. No need to self create tables.
  10. It creates tables in database according to needs.

Supported Databases:
Hibernate supports almost all the major RDBMS. Following is a list of few of the database engines supported by Hibernate:
  1.  HSQL Database Engine
  2.  Oracle
  3.  Microsoft SQL Server Database
  4.  Sybase SQL Server
  5.  Informix Dynamic Server
  6.  DB2/NT
  7.  MySQL
  8.  PostgreSQL
  9.  FrontBase

Manipulation usings Swings in java

Data Manipulation Using Swings in java:-

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class database extends JFrame implements ActionListener
{
Connection con;
Statement st;
ResultSet rs;
JLabel l3=new JLabel("Select id");
JLabel l=new JLabel("Emp id");
JLabel l1=new JLabel("Name");
JLabel l2= new JLabel("Department");
JComboBox c=new JComboBox();
JTextField t=new JTextField();
JTextField t1=new JTextField();
JTextField t2=new JTextField();
JButton b=new JButton("Insert");
JButton b1=new JButton("Delete");
JButton b2=new JButton("Update");
JButton b3=new JButton("Select");
JButton b4=new JButton("Clear");

Thursday, 4 May 2017

Working of Tomcat Server

Tomcat Working:-

Working of Tomcat Server Tomcat:-
Tomcat is a servlet container. It implements only the servlets and jsp specification.
Tomcat makes use of Sun Microsystems specific specifications.
Tomcat, developed by Apache (www.apache.org), is a standard reference implementation for Java servlets and JSP. It can be used standalone as a Web server or be plugged into a Web server

1. Installation:-

You can download Tomcat from

http://tomcat.apache.org/download-60.cgi

Before running the servlet, you need to start the Tomcat servlet engine. To start Tomcat, you have to first set the JAVA_HOME environment variable to the JDK home directory.

By default, Tomcat runs on part 8080. You can change it to a different port.

Customer Bill Information in java

Program Of Customer Bill Information:

package package1;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class array5 extends Applet implements ActionListener
{
int i,p,q,r;
  Label lab=new Label("CUSTOMER BILL INFORMATION");
Label l1=new Label("NAME");
Label l2=new Label("PRODUCT CODE");
Label l3=new Label("PRODUCT CATEGORY");
Label l4=new Label("PRICE");
Label l5=new Label("QUANTITY");
TextField t1=new TextField();
TextField t2=new TextField();
TextField t3=new TextField();
Choice ch1=new Choice();
Choice ch2=new Choice();
List ls=new List();
Button b=new Button("BILL");
public void init()
{

Sum of Array Matirx in java

Printing Sum of array matrix using Scanner class:-

import java.util.Scanner;
public class arr_sum_matrix 
{
public static void main(String[] args) 
{
Scanner sc=new Scanner(System.in);
int a[]=new int[50];
int b[]=new int[50];
int c[]=new int[100];
int y,n;
System.out.println("ENTER FIRST SIZE OF YOUR ARRAY");
n=sc.nextInt();
for(y=0;y<n;y++)
{
a[y]=sc.nextInt();

Printing array values in java

How to Print array values:-

public class arr_console
{
public static void main(String[] args) 
{
int i;
String[] name=new String[4];
name[0]="MY NAME";
name[1]="IS";
name[2]="BALWANT";
name[3]="SINGH";
for(i=0;i<name.length;i++)
{
System.out.println(name[i]);
}
}
}
As mentioned above we have created an array with length 4.
It will store four String values.And there is use of for loop to retrieve all the values of array.

ActionListener Implementation in Swings

How to Implement ActionListener  in java:-

import java.applet.Applet;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
public class action_lis extends Applet implements ActionListener
{
Button b=new Button("CHECKED IT OUT");
Button b1=new Button("PRINT");
public void init()
{
this.setLayout(null);
b.setBounds(300,300,120,70);
b1.setBounds(500,300,120,70);
add(b);
add(b1);
b.addActionListener(this);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent ar)
{
if(ar.getSource()==b)
{
JOptionPane.showMessageDialog(null,"MY NAME IS BALWANT");
}
if(ar.getSource()==b1)
{
JOptionPane.showMessageDialog(null,"YOU HAVE BEEN PRINTING 100 PAGES");
}
}
}
Basically actionlistener is used  to trigger a particular event.
In this program i have created two buttons named as b and b1. Button b is named as CHECKED IT OUT and Button b1 named as PRINT . On clicking Button b it will open an dialog box which will show "MY NAME IS BALWANT".  On clicking Button b1 it will open an dialog box which will show  "YOU HAVE BEEN PRINTING 100 PAGES".

OUTPUT:

First it will show as given below:

How-to-implement-ActionListener-in-Swings-in-java

When You click CHECKED IT OUT it will show as given below:

How-to-implement-ActionListener-in-Swings-in-java


When you will click PRINT it will show as given below:

How-to-implement-ActionListener-in-Swings-in-java

You can check this link for how to do manipulation using swings.



Also you can check how to make Registration Form using Swings in java:


https://wingsofm.blogspot.in/2017/05/registration-form-using-swings-in-java.html

Monday, 1 May 2017

Github Tutorial for Beginners

GITHUB INTRODUCTION:

 Github is a web-based Git or version control repository.GitHub offers both plans for private and free repositories on the same account which are commonly used to host open-source software projects.With the help of GitHub you can easily create your own repository in your local system, then you can push all your code to web server repository which is provided by GitHub.
You can create private repository as well as public repository.
Private repository is a paid repository and public repository is free.
You can choose anyone.

Git can be easily installed locally on your system. You can easily download git for your pc from the link given below.

Tuesday, 25 April 2017

Difference b/w JAR,WAR and EAR

DIFFERENCE BETWEEN JAR , WAR AND EAR ...

JAR:-  JAR  known as Java ARchive is a package file format used to combine many Java class files and along with associated metadata and resources (text, images) into one file for the distribution.
Difference b/w JAR,WAR and EAR


WAR:-  A WAR file known as Web application ARchive is similarly like a JAR file used to distribute a collection of JavaServer Pages, Java Servlets, Java classes, XMLfiles, tag libraries, web pages (HTML and related files) and other resources that together make a web application.

Difference b/w JAR,WAR and EAR



Basically .war file is contained in your project in dist folder.Also .war file is created when you clean and build your project.

EAR:- EAR  known as Enterprise Application ARchive is a file format used by Java EE(ENTERPRISE EDITION) for packaging one or more modules into a single archive so that the deployment of the various modules onto an application server happens very simultaneously and frequenlty.


Difference b/w JAR,WAR and EAR

Friday, 3 February 2017

Tuesday, 31 January 2017

Example to retrieve image from Oracle database:

Retrieving image from Oracle database

PreparedStatement: we can retrieve and store the image in the database.

The getBlob() method of PreparedStatement is used to get Binary information, it returns the instance of Blob. After calling the getBytes() method on the blob object, we can get the array of binary information that can be written into the image file.

public Blob getBlob()throws SQLException
Signature of getBytes() method of Blob interface

public byte[] getBytes(long pos, int length)throws SQLException

We are assuming that image is stored in the imgtable.

CREATE TABLE "IMGTABLE"
( "NAME" VARCHAR2(4000),
"PHOTO" BLOB
)

Now let's write the code to retrieve the image from the database and write it into the directory so that it can be displayed.


JavaCoders

CODING AND PROGRAMMING:

This blog contains all the information regarding java coding and the programs, where all the coders can share and learn. This blog contains all the codes regarding:

JSP
Servlets
Hibernate
Core Java
Advanced Java
Github
Programs regarding Strings..

Please comments ,share the posts and follow for more posts..

Oracle / PLSQL: FOR LOOP

set serveroutput on; declare a1 varchar2(100); begin select count(*) into a1 from employees; for i in 1..a1 loop dbms_output.put_line...