Saturday 9 November 2013

How to clean your RAM Memory

create a new text file on your desktop and call it  "RAMcleaner" or something...

Type

FreeMem=Space(64000000)

in this file and save it as RAMcleaner.vbs

 [ You may choose the "All Files" option when u save it ]

Run the file and ur RAM may be cleaned :>

Of course u can edit the code in the file for a greater "cleaning-progress".


FreeMem=Space(1280000000)

How to find asci value using c language code

#include<stdio.h>
void main()
{
  int ch;
  clrscr();
  printf("\n\n\t\tpress any key to see asci value");
   ch=getch();
    printf("\n\nENTERED KEY CODE IS :::>%d",ch);
  getch();
}

How to read password from user in c language

/* Programm for enter password from user
Programming Language c
*/


#include<stdio.h>
void main()
{

  char pass[100],ch;
  int i=0,j;
  clrscr();
  printf("\n\n\tENTER YOUR PASSWORD\n\t");
  do
  {

   ch=getch();
   if(ch!=0x0d)
   {
   pass[i]=ch;
   printf("*");
   i++;
   }

  } while(ch!=0x0d);
  getch();
  printf("\n");
  printf("\n\n\n\tYOUR PASSWORD\n\t");

  for(j=0;j<i;j++)
  {
   printf("%c",pass[j]);
  }

  getch();
}

how to write byte into file in java

import java.io.*;
class writebyte
{
           public static void main(String a[])
           {
              int i =0;
             byte arr[]={'t','a','n','m','a','y'};
              FileOutputStream outfile=null;
              try
              {
                  outfile=new FileOutputStream("tanmay.txt");
                  outfile.write(arr);
                  outfile.close();
              }
              catch(IOException e)
              {
                 System.out.println(e);
                 System.exit(-1);
              }
           }
    }

how to read charcter in java

 import java.io.*;
class readchar

   public static void main(String a[])
   {
         FileReader ins=null;
         int b;
         try
         {
           ins=new FileReader(a[0]);
            while((b=ins.read())!=-1)
            {
              System.out.println((char)b);
            }
            ins.close();
         }
         catch(IOException e)
         {
           System.out.println(e);
         }
      }
}

How to pring first 25 prime number in java

class prime
{
    public static void main(String args[])
    {
        int c=1,i,no,p;
        no=1;
        while(c<=25)
        {
               p=1;
            for(i=2;i<=no/2;i++)
            {
            if(no%i==0)
            {
               p=0;
               break;
            }
             }
        if(p==1)
        {
            System.out.println(no);
        }
         c++;
         no++;
        }
    }               
}

How to pring first 25 prime number in java

class prime
{
    public static void main(String args[])
    {
        int c=1,i,no,p;
        no=1;
        while(c<=25)
        {
               p=1;
            for(i=2;i<=no/2;i++)
            {
            if(no%i==0)
            {
               p=0;
               break;
            }
             }
        if(p==1)
        {
            System.out.println(no);
        }
         c++;
         no++;
        }
    }               
}

how to select data from databse with java swing

 First of all set your Database:
    STEP 1: goto your contorl panal
                ->Adminstrative tool
                ->Data Source (ODBC)
  STEP 2: Add new Microsoft Access  driver (*.mdb,*.accdb)
                ->select your database from pressing select button
                ->Databse name as  login1
                 ->then ok and ok
 enjoy....!!! below code
cretae java file compile it ....!!!!

-------------------------------------------------------------------------------------------------------------


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package swingtest;
import java.awt.Container;
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.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
/**
 *
 * @author #Dx Panchal
 */
public class SwingTest extends JFrame implements ActionListener{

    Container c=getContentPane();
    private JButton btnlogin,btncancle;
    private JLabel lbluser,lblpswd;
    private JTextField txtuser;
    private JPasswordField txtpswd;
   
    public SwingTest()
    {
    super("Login");
    this.setSize(400,200);
    this.setLayout(null);
    this.setResizable(false);
    this.setLocation(45,45);
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
   
    btnlogin=new JButton("LOGIN");
    btncancle=new JButton("CANCLE");
    lbluser=new JLabel("USER NAME:");
    lblpswd=new JLabel("PASSWORD :");
    txtuser=new JTextField();
    txtpswd=new JPasswordField();
   
    lbluser.setBounds(50, 40, 140, 25);
    txtuser.setBounds(150, 40, 130, 25);
    lblpswd.setBounds(50, 80, 140, 25);
    txtpswd.setBounds(150,80,130,25);
    btnlogin.setBounds(150, 120, 100, 25);
    btncancle.setBounds(250, 120, 100, 25);
   
 
   
    btnlogin.addActionListener(this);
    btncancle.addActionListener(this);
   this.add(btnlogin);
   this.add(btncancle);
   this.add(lbluser);
   this.add(lblpswd);
   this.add(txtuser);
   this.add(txtpswd);
  
    }
   
     public void actionPerformed(ActionEvent e) {
         if(e.getSource()==btnlogin)
         {
           
         
             try
              {
                     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
             Connection con=DriverManager.getConnection("Jdbc:Odbc:login1");
                 try
                 {
                     Statement st = con.createStatement();
               
                      ResultSet rs=st.executeQuery("SELECT *FROM login WHERE username='"+
                              txtuser.getText()+"'AND password='"+txtpswd.getText()+"'");
                     if(rs.next())
                     {
                     
                         if(rs.getString(2).equals(txtuser.getText())&&rs.getString(3).equals(txtpswd.getText()))
                       {
                       JOptionPane.showMessageDialog(null,"Sucessfully Login","Correct..!!!",JOptionPane.OK_OPTION);
                 
                     }
                     }
                      else
                     { JOptionPane.showMessageDialog(null,"Invalid USERNAME and PASSWORD","Invalid",JOptionPane.ERROR_MESSAGE);
                  }
                   
                    
                 }
                 catch(Exception ex1)
                 {
                 JOptionPane.showMessageDialog(null, "Invalid username or password", "Invalid", JOptionPane.ERROR_MESSAGE);
                   txtuser.setText("");
                   txtpswd.setText("");
                 }
                 con.close();
              }
              catch(Exception ex)
              {
                   JOptionPane.showMessageDialog(null, "Unable to connect to the database", "Connection error", JOptionPane.ERROR_MESSAGE);
     
              }
             
                 
         }
        
         if(e.getSource()==btncancle)
         {
         txtuser.setText("");
         txtpswd.setText("");
        
         }
    
     }
    
    public static void main(String[] args) {
        new SwingTest().setVisible(true);
       
    }
}

how to insert data into database with java swing

 First of all set your Database:
    STEP 1: goto your contorl panal
                ->Adminstrative tool
                ->Data Source (ODBC)
  STEP 2: Add new Microsoft Access  driver (*.mdb,*.accdb)
                ->select your database from pressing select button
                ->Databse name as  login1
                 ->then ok and ok
 enjoy....!!! below code
cretae java file compile it ....!!!!
----------------------------------------------------------------------------------------------------------
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.Statement;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
/**
 *
 * @author #Dx Panchal
 */
public class Registration extends JFrame implements ActionListener {
    Container c=getContentPane();
    private JLabel lbluser,lblpswd,lblcpswd;
    private JTextField txtuser;
    private JPasswordField txtpswd,txtcpswd;
    private JButton btnreg,btncnl;
    public Registration()
    {
    super("Registration");
    this.setSize(400,600);
    this.setLayout(null);
    this.setResizable(false);
    this.setLocation(45,45);
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
   
    lbluser=new JLabel("Enter Username:");
    lblpswd=new JLabel("Enter Password:");
    lblcpswd=new JLabel("Repeat Password:");
    txtuser=new JTextField();
    txtpswd=new JPasswordField();
    txtcpswd=new JPasswordField();
    btnreg=new JButton("Register");
    btncnl=new JButton("Cancle");
   
    lbluser.setBounds(50,60,140,25);
    txtuser.setBounds(160,60, 140, 25);
    lblpswd.setBounds(50,100, 140, 25);
    txtpswd.setBounds(160,100, 140, 25);
    lblcpswd.setBounds(50,140, 140, 25);
    txtcpswd.setBounds(160,140, 140, 25);
    btnreg.setBounds(160, 180,100, 25);
    btncnl.setBounds(280,180,100,25);
   
   
    this.add(lbluser);
    this.add(txtuser);
    this.add(lblpswd);
    this.add(txtpswd);
    this.add(lblcpswd);
    this.add(txtcpswd);
    this.add(btnreg);
    this.add(btncnl);
   
    btnreg.addActionListener(this);
    btncnl.addActionListener(this);
   
    }
    public void actionPerformed(ActionEvent e)
    {
    if(e.getSource()==btnreg)
    {
        try
        {
           Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
           Connection con=DriverManager.getConnection("Jdbc:Odbc:login1");
           Statement st=con.createStatement();
           try
           {
               String username=txtuser.getText();
               String password=txtpswd.getText();
               String cpassword=txtcpswd.getText();
               if(!cpassword.equals(password))
               {
                JOptionPane.showMessageDialog(null,"Password does not match...!!! ","Error",JOptionPane.ERROR_MESSAGE);
               txtuser.setText("");
               txtpswd.setText("");
               txtcpswd.setText("");
               return;
               }
              String str="INSERT INTO login(username,password) values('"+username+"','"+password+"')";
              PreparedStatement ps=con.prepareStatement(str);
              ps.executeUpdate();
             JOptionPane.showMessageDialog(null,"Congratulation your registration done successfully..!!","Thanks to join",JOptionPane.INFORMATION_MESSAGE);
              
           }
           catch(Exception x)
           {
                     JOptionPane.showMessageDialog(null, "Error,Unable to perform database operation", "Error", JOptionPane.ERROR_MESSAGE);
      
           }
        }
        catch(Exception ex)
        {
         JOptionPane.showMessageDialog(null, "Error on database connection, Cannot perform database operation", "Error", JOptionPane.ERROR_MESSAGE);
  
        }
       
    }
   
    if(e.getSource()==btncnl)
    {
    txtuser.setText("");
               txtpswd.setText("");
               txtcpswd.setText("");
   
    }
   
       
    }
    public static void main(String args[])
    {
         new Registration().setVisible(true);   
    }
}

How to change Background color by selecting color from Listview

activitymain.xml file::> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     xm...