Posts

Showing posts from 2013

Quantum Internet Benefits

Image
  The quantum internet is a network of quantum computers that are connected together using quantum communication. It has the potential to revolutionize many industries, including: Secure communications: The quantum internet would be inherently secure, as it would be impossible to eavesdrop on quantum communications without being detected. This could be used for applications such as secure financial transactions, government communications, and military applications. Quantum computing: The quantum internet would allow quantum computers to be connected together, which would allow them to solve problems that are currently impossible for classical computers. This could be used for applications such as drug discovery, financial modeling, artificial intelligence, and materials science. Quantum sensors: The quantum internet could be used to connect quantum sensors together, which would allow them to create a global network of sensors that could be used to monitor the environment, detect earthq

How to create and execute stored procedure in linux mysql command? [ Linux Mysql: Create and execute stored procedures ]

Image
Sql Scripts for creating stored procedures: mysql > delimiters // mysql > use userDB;           > select database();           > create procedure userdbprdt()           >  begin           >  select u.id,u.name,u.username,ur.product from usertbl u join userproduct ur where u.id=ur.id;             > end// Sql script for executing stored procedure mysql> call userdbprdt()//

Java Swing MySql JDBC: insert data into database

Image
Program import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.sql.*; public class insertswing implements ActionListener {   JFrame fr;JPanel po;   JLabel l1,l2,main;   JTextField tf1,tf2;   GridBagConstraints gbc;   GridBagLayout go;   JButton ok,exit; public insertswing(){ fr=new JFrame("New User Data "); Font f=new Font("Verdana",Font.BOLD,24); po=new JPanel(); fr.getContentPane().add(po); fr.setVisible(true); fr.setSize(1024,768); fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); po.setBackground(Color.WHITE); go=new GridBagLayout(); gbc=new GridBagConstraints(); po.setLayout(go); main=new JLabel("Enter User Details "); main.setFont(f); l1=new JLabel("Name  :");tf1=new JTextField(20); l2=new JLabel("User Name  :");tf2=new JTextField(20); ok=new JButton("Accept"); exit=new JButton("Exit"); gbc.anchor=GridBagConstraints.NORTH;gbc.gridx=5;gbc.gridy=0; go.s

MySql linux terminal Commands: Basic commands to create and drop databases commands

Image
1. Login on mysql  command mysql -u root -h localhost -p 2. Check Status mysql> status 3. show databases mysql> show databases; 4. Show variables mysql> show variables; 5. Show processlist mysql> show processlist; 6. Using and selecting system already available mysql database mysql> use mysql; mysql> select database(); 7. select user table in mysql database mysql> select Host, User from user or mysql> select Host, User from mysql.user 8. Create database and display it mysql> create database tempDB; mysql> show databases; mysql> use tempDB; mysql> select database(); 9. Drop database  mysql> drop database tempDB;  mysql> show databases; 10. exit  mysql   mysql> exit  

Data Structure and Algorithms : Queue Program in Java

Image
Program: public class queuepgm { private int maxSize; private long[] queArray; private int front; private int rear; private int nItems; public queuepgm(int s) { maxSize = s; queArray = new long[maxSize]; front = 0; rear = -1; nItems = 0; } public void enqueue(long j) { if(rear == maxSize-1) rear = -1; queArray[++rear] = j; nItems++; } public long dequeue() { long temp = queArray[front++]; if(front == maxSize) front = 0; nItems--; return temp; } public long peekFront() {     return queArray[front]; } public boolean isEmpty()       { return (nItems==0); } public boolean isFull() { return (nItems==maxSize); } public int size() { return nItems; } public static void main(String[] args) { queuepgm theQueue = new queuepgm(5); // queue holds 5 items theQueue.enqueue(10); theQueue.enqueue(20); theQueue.enqueue(30); theQueue.enqueue(40); System.out.println("Dequeue Values: FIFO"); while( !theQueue.isEmpty() ) { long n = th

Data Structure and Algorithms : Stack Program in Java

Image
Program public class stackpgm { private int maxSize; private long[] stackArray; private int top; public stackpgm(int s) { maxSize = s; stackArray = new long[maxSize]; top = -1; } public void push(long j) {     if(!isFull())     {       stackArray[++top] = j;     } } public long pop() {           return stackArray[top--];             } public long peek() { return stackArray[top]; } public boolean isEmpty() { return (top == -1); } public boolean isFull() { return (top == maxSize-1); } public static void main(String[] args) { stackpgm theStack = new stackpgm(10); theStack.push(1); theStack.push(2); theStack.push(3); theStack.push(4); System.out.println("Pop up values"); while( !theStack.isEmpty() ) { long value = theStack.pop(); System.out.print(value+"\n"); } } } Output

Head and Tail Commands in Linux

Image
Head Command Description : prints output of first part of the file by default it will print first 10 lines Syntax : head filename examples: 1.  head upcasting.java it will print first 10 lines of the file upcasting.java by default. 2. head -n 50 upcasting.java  it will print first 50 lines of the file upcasting.java. 3. head upcasting.java downcasting.java it will print first 10 line of the 2 files upcasting.java and downcasting.java. 4. head *.java it will print all the java files first 10 lines. 5. head *.java *.class it will print all the java and class files first 10 lines. Tail Command: Description : prints output of last part of the file by default it will print last 10 lines Syntax : tail filename Examples: 1. tail upcasting.java it will print last 10 lines of the file upcasting.java by default. 2.  tail -n 50 upcasting.java  it will print last 50 lines of the file upcasting.java. 3.  tail upcasting.java downcasting.java it will pr

Linux Terminal Commands

Image
Install Command sudo apt-get install <package-name> Example: Installing vlc media player sudo apt-get install vlc ls Command ls -l list folders and files with read write permissions and user groups ls -a This command shows hidden files and folders ls -al ls -la Clear Command clear this command clears the screen Manual Command man <command> this command shows manual of the commands example man ls shows manual command of ls q to quit the manual screen back to terminal commands ifconfig command ifconfig command ip network address details netstat command netstat command used to show network status like ip addresses of local and foreign; port, pid, network protocols cat Command   cat  command  concatenate files and print on the standard output.

Java Program: Down casting Inheritence

Image
Program public class downcasting {    public static void main(String[] args)     {      fordd f;      benzz b;      BMWw bm;      carr c,cc,ccc;      c=new fordd();      cc=new benzz();      ccc=new BMWw();      f=(fordd)c; // downcasting or narrowing or specialization      b=(benzz)cc;      bm=(BMWw)ccc;      f.car();      b.car();      bm.car();     } } class carr {     void car()     {         System.out.println("This super class car method");     } } class fordd extends carr {     void car()     {         System.out.println("This sub class Ford car method");     } } class benzz extends carr {      void car()     {         System.out.println("This sub class Benz car method");     } } class BMWw extends carr {      void car()     {         System.out.println("This sub class BMW car method");     } } Output

Java Program: Up casting Program in inheritance

Image
Program public class upcasting {    public static void main(String[] args)     {      car c,cc,ccc,o;      o=new car();      o.car(); //no casting      c=(car)new ford(); //upcasting ford sub class to super class      c.car();      cc=(car)new benz();//upcasting ford sub class to super class      cc.car();      ccc=(car)new BMW();//upcasting ford sub class to super class            ccc.car();         } } class car {     void car()     {         System.out.println("This super class car method");     } } class ford extends car {     @Override     void car()     {         System.out.println("This sub class Ford car method");     } } class benz extends car {      @Override     void car()     {         System.out.println("This sub class Benz car method");     } } class BMW extends car {      @Override     void car()     {         System.out.println("This sub class BMW car method");     } } Output

Java Program: Inheritance Super Keyword

Image
Program class inheritance {  public static void main(String[] args)  {   apple a=new apple();   a.disp();  } } class fruit {  String f="fruit";  public void disp()  {   System.out.println("Base Class "+f);  } } class apple extends fruit {  String f="Apple";  public void disp()  {   System.out.println("Derived Class  "+f);   super.disp();   System.out.println("Super Class "+super.f);  } } Output

Java Program: File I/O Fileoutputstream to create file

Image
Program import java.io.*; public class createfile {     public static void main(String[] args)     {         try         {         createfile();         }         catch(Exception ex)         {             System.out.println("File Exceptio occured");         }         }     public static void createfile() throws java.io.IOException     {         DataInputStream d=new DataInputStream(System.in);         FileOutputStream f=new FileOutputStream("jack.txt",true);         BufferedOutputStream b=new BufferedOutputStream(f,1024);         System.out.println("Enter $ at the end to finish text");         char c;         while((c=(char)d.read())!='$')         {             b.write(c);                   }         b.close();     } } Output

Java Program: AWT Frame Closing Event

Image
Program import java.awt.*; import java.awt.event.*; public class awtexample extends Frame{     public static void main(String[] args)     {         Frame f= new Frame("New Frame");         f.setSize(400, 500);         f.setVisible(true);         f.addWindowListener(new WindowAdapter(){         public void windowClosing(WindowEvent e)         {         System.exit(0);         }      });     } } Output

Java Program: Multi Thread optimum way utilize CPU time using Thread(Runnable object, String thread_name)

Program i mport java.util.logging.Level; import java.util.logging.Logger; class ThreadRunnnable {     public static void main(String[] args)     {                new ThreadRun();        new ThreadRunn();        System.out.println("Main Thread Starts");         for(int i=1;i<=5;i++)         {             System.out.println(i);             try {                 Thread.sleep(1500);             } catch (InterruptedException ex) {                 Logger.getLogger(ThreadRun.class.getName()).log(Level.SEVERE, null, ex);             }         }                         } } class ThreadRun implements Runnable {     ThreadRun()     {                 Thread t=new Thread(this,"Thread1");         t.start();         System.out.println("Thread 1");             }     @Override     public void run()     {         for(int i=1;i<=5;i++)         {             System.out.println(i);             try {                 Thread.sleep(5

Java Program: Thread using Runnable interface program

Program import java.util.logging.Level; import java.util.logging.Logger; class ThreadRunnnable {     public static void main(String[] args)     {              new ThreadRun();        new ThreadRunn();        System.out.println("Main Thread Starts");         for(int i=1;i<=5;i++)         {             System.out.println(i);             try {                 Thread.sleep(1500);             } catch (InterruptedException ex) {                 Logger.getLogger(ThreadRun.class.getName()).log(Level.SEVERE, null, ex);             }         }                 } } class ThreadRun implements Runnable {     ThreadRun()     {               Thread t=new Thread();         t.start();         System.out.println("Thread 1");         run();     }     @Override     public void run()     {         for(int i=1;i<=5;i++)         {             System.out.println(i);             try {                 Thread.sleep(500);             } catch (Inter

Java Program: Thread in swing implements Runnable interface and SwingUtilities

Image
Program import javax.swing.*; public class SwingThread extends JFrame {     public static void main(String[] args) {     SwingUtilities.invokeLater(new Runnable() {       @Override       public void run() {         final JFrame f = new JFrame("Swing using Thread Frame 1");         f.setSize(600, 400);         f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);         f.setVisible(true);               final JFrame fr = new JFrame("Swing using Thread Frame 2");         fr.setSize(600, 600);         fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);         fr.setVisible(true);       }     });     }   } Output:

Java Program: Simple Thread Example

Image
public class threadexample {     public static void main(String args[])     {         Thread t=Thread.currentThread();         System.out.println("Current Thread: "+t);         t.setName("Thread Example");         System.out.println("Current Thread Name changed as: "+t);     } } output

Java Program: Swap two numbers without temp variable

import java.io.*; public class Swapwithouttemp {     public static void main(String[] args) throws IOException     {         System.out.println("Enter first number");         BufferedReader br=new BufferedReader(new InputStreamReader(System.in));         int x=Integer.parseInt(br.readLine());             System.out.println("Enter second number");         BufferedReader brr=new BufferedReader(new InputStreamReader(System.in));         int y=Integer.parseInt(brr.readLine());                 new swap(x,y);     } } class swap {       swap(int a, int b) throws IOException               {         System.out.println("Before swapped values a= "+a+"\tb= "+b );         a=a+b;         b=a-b;         a=a-b;         System.out.println("After swapped values a= "+a+"\tb= "+b );     } }

Java Program: User defined input using BufferedReader, Checking Employee Age

import java.io.*; public class EmployeeAgeCheck {     public static void main(String[] args) throws IOException     {         EmployeeData e=new EmployeeData();         e.getdetails();         e.checkage();           } } class EmployeeData {     private String name;     private int age;     public void getdetails() throws java.io.IOException     {         // user defined input at runtime         BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));         System.out.println("Enter name");         name=buf.readLine();         System.out.println("Enter Age");         age=Integer.parseInt(buf.readLine());     }     public void checkage()     {         if(age<=30)         {             System.out.println(name+ " ,You're Junior Employee");         }         else         {             System.out.println(name+ " ,You're Senior Employee");         }     } }

Java Program : Default and Parameterized Constructor

public class constructorexample {     public static void main(String[] args)     {         personcon kumaran=new personcon();         kumaran.display();         personcon jannu=new personcon("Jannu",22);         jannu.display();     } } class personcon {     private String name;     private int age;     //default constructor     personcon()     {         name="kumaran";         age=23;     }    //parameterized constructor     personcon(String n,int a)               {         name=n;         age=a;     }     public void display()     {         System.out.println("Name: "+name+"\t Age: "+age);     } }

How to download google chrome browser in linux using terminal command?

Image
Step 1: Download Google Chrome For 32 bit version $ wget https://dl.google.com/linux/direct/google-chrome-stable_current_i386.deb For 64 bit version $ wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb Step 2: Install .deb file For 32 bit version $ sudo dpkg -i google-chrome-stable_current_i386.deb For 64 bit version $ sudo dpkg -i google-chrome-stable_current_amd64.deb Issues: if you get any error while installing or downloading just use this below command to clear the issues 1. $ sudo apt-get update 2. $ sudo apt-get upgrade 3. $ sudo apt-get -f install After installation check it google chrome in linux dash home search:

How to check CPU usage in Linux OS?

Image
Generally top is a command to check CPU usage on any OS. top command htop Command In Linux Terminal command to CPU usage htop is another to do the task but before install htop as:  Sudo apt-get install htop  in terminal then after use htop command other than iostat,  /proc/meminfo,mpstat are the commands to be used to check CPU  and memory usages

Compress Data using ASCII Values and Decompress data to get back original ASCII

public class StrAscii {          public static void main(String[] args)     {               StrAscii.stringToBytesASCII("Apple");     }          public static byte[] stringToBytesASCII(String str) {  byte[] b = new byte[str.length()];  for (int i = 0; i < b.length; i++) {      System.out.println("Before Ascii "+i+" ="+b[i]);   b[i] = (byte) str.charAt(i);   System.out.println("After Ascii "+i+" ="+b[i]);   StrAscii sa=new StrAscii();      System.out.println("Compressed data Bytes "+i+" ="+sa.compressbyte(b[i]));   System.out.println("Compressed data Slots "+i+" ="+sa.compressslot(b[i]));   System.out.println("Decompressed data "+i+" ="+ (sa.compressbyte(b[i])*9+sa.compressslot(b[i])));  }  return b; }  public long compressslot(long x)  {      x = x%9;      return x;  }  public long compressbyte(long y)  {      y = y/9;      return y;  }

Four Sequential or series Squared Numbers Formula's in two cases

Image
In this I've observed and innovated new shortcut Math formula of Four Sequential or series Squared Numbers Formula's in two cases; Case 1: Only applicable for positive numbers; Case 2: it will be applicable both negative and positive numbers in those series; Condition : d- difference must be unique; See below pictures that I've made it in two formulas

Login and Registration forms in C# windows application with Back end Microsoft SQL Server for data access

Image
In this article, I'm gonna share about how to make login and register form with MS SQL database; 1. Flow Chart Logic 2. Normal Features 3. Form Designs Login Form Design Sign in Form Design Password Retrieve Form 4. Database Design and SQL queries and Stored Procedure Create new Database as "schooldata" create table registerdata (  ID int identity,  Username nvarchar(100),  Password nvarchar(100),  Fullname  nvarchar(100),  MobileNO nvarchar(100),  EmailID nvarchar(100)  ) select * from registerdata create procedure regis (  @Username as nvarchar(100),  @Password as nvarchar(100),  @Fullname as nvarchar(100),  @MobileNO as nvarchar(100),  @EmailID as nvarchar(100)  ) as begin insert into registerdata (Username, Password, Fullname, MobileNO,EmailID) values (@Username, @Password, @Fullname, @MobileNO, @EmailID) end 5. App.config Settings <?xml versio