Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Sunday, 19 January 2014

JDBC Connection for Postgres


STEPS :
1.Download the postgre JDBC driver
2.While executing the program first  GRANT ALL PRIVILEGES ON TABLE ttt TO aaa;
3.set the class path for the .jar driver
 export CLASSPATH=/home/exam/Desktop/postgresql.jar:.
4.execute the program



import java.sql.Connection; 
import java.sql.DriverManager; 
import java.sql.ResultSet; 
import java.sql.Statement;
import java.util.*;
 
/**
 * @author www.javaworkspace.com
 * 
 */ 


public class ConnectPostgre { 
    public static void main(String[] args) { 
        Connection connection = null; 
        ResultSet resultSet = null; 
        Statement statement = null; 
 
        try { 
            Class.forName("org.postgresql.Driver"); 
            connection = DriverManager.getConnection( 
                    "jdbc:postgresql://localhost:5432/jobportal", "postgres","kiran"); 
            statement = connection.createStatement();
             
             Scanner sc=new Scanner(System.in);
             System.out.println("enter data for new company:cid;name;branch;email;website;address;username;password");
             cid=sc.nextInt();
             name=sc.next();
             branch=sc.next();
             email=sc.next();
             website=sc.next();
             address=sc.next();
             username=sc.next();
             password=sc.next();
             
             //String sql = "INSERT INTO patient " +
               //    "VALUES (4, 'Zara', 'Ali','nama','2013-06-10' ,'1993-6-5')";
             String sql = "INSERT INTO company " +
                   "VALUES ("+cid+", '"+name+"', '"+branch+"','"+email+"','"+website+"' ,'"+address+"' ,'"+username+"' ,'"+password+"')";
             statement.executeUpdate(sql);


 
            resultSet = statement.executeQuery("SELECT * FROM company"); 
            while (resultSet.next())
          { 
               System.out.print("Company NAME:" 
                        + resultSet.getString("name"));
               System.out.print("    Company Branch:" 
                        + resultSet.getString("branch"));
               System.out.print("    Company Email:" 
                        + resultSet.getString("email"));
               System.out.print("    Companyt Website:" 
                        + resultSet.getString("website"));
               System.out.println("    Company Address:" 
                        + resultSet.getString("address"));
           System.out.println("    Company Username:" 
                        + resultSet.getString("username")); 
               System.out.println("    Company Password:" 
                        + resultSet.getString("password"));
 

            }
           //System.out.println("enter data for new patient:id;fname;mname;lname;apptime;dob")
           //int id ;String fname,mname,lname;
          
           
        } catch (Exception e) { 
            e.printStackTrace(); 
        } finally { 
            try { 
                resultSet.close(); 
                statement.close(); 
                connection.close(); 
            } catch (Exception e) { 
                e.printStackTrace(); 
            } 
        } 
    } 
}                                                           

                                                               OLD OUTPUT
exam@exam-OptiPlex-390:~/Desktop$ export CLASSPATH=/home/exam/Desktop/postgresql.jar:.
exam@exam-OptiPlex-390:~/Desktop$ javac ConnectPostgre.java
exam@exam-OptiPlex-390:~/Desktop$ java ConnectPostgre

patient FNAME:ramu
patient MNAME:papu
patient LNAME:lal
patient time:2013-10-10   
patient DOB:1993-10-10

patient FNAME:asd 
patient MNAME:ssss
patient LNAME:2er 
patient time:null   
patient DOB:1993-06-12

patient FNAME:qqqq 
patient MNAME:cu  
patient LNAME:okedemes 
patient time:2013-01-04   
patient DOB:2013-06-08

exam@exam-OptiPlex-390:~/Desktop$



                                                              NEW OUTPUT


exam@exam-OptiPlex-390:~/Desktop$ export CLASSPATH=/home/exam/Desktop/postgresql.jar:.
exam@exam-OptiPlex-390:~/Desktop$ javac ConnectPostgre.java exam@exam-OptiPlex-390:~/Desktop$ java ConnectPostgreenter data for new patient:id;fname;mname;lname;apptime;
dob
6
new
tttt
yyyy
2013-2-5
1995-2-1

patient FNAME:ramu 
patient MNAME:papu
 patient LNAME:lal 
patient time:2013-10-10   
patient DOB:1993-10-10

patient FNAME:asd
 patient MNAME:ssss
 patient LNAME:2er 
patient time:null 
 patient DOB:1993-06-12

patient FNAME:qqqq
 patient MNAME:cu  
patient LNAME:okedemes
 patient time:2013-01-04 
 patient DOB:2013-06-08

patient FNAME:Zara 
patient MNAME:Ali
patient LNAME:nama
patient time:2013-06-10 
 patient DOB:1993-06-05

patient FNAME:w 
patient MNAME:aa 
patient LNAME:aaa
 patient time:2013-05-09 
 patient DOB:1993-05-04

patient FNAME:new 
patient MNAME:tttt 
patient LNAME:yyyy
patient time:2013-02-05   
patient DOB:1995-02-01

exam@exam-OptiPlex-390:~/Desktop$


*/
                                       

Installing Wireshark on Ubuntu 12.04 LTS

Installing wireshark on Ubuntu 12.04 LTD and limiting packet capture to one group, in this case the group wireshark. I’m sure you can use these instructions for other debian based distributions.
Although you’ll have to take it as read that I’ve only tested it on Ubuntu, feel free to let me know if it doesn’t and I’ll amend the instructions to suit.
First, we install Wireshark from the terminal.

Installing Wireshark

sudoapt-get install wireshark
No interface can be used for capturing in this system with the current configuration

If you run wireshark as a non root user at this stage (see image above), you will get the message “No interface can be used for capturing in this system with the current configuration.”. The following steps will rectify this.

Create the wireshark group.
sudo groupadd wireshark
Add your username to the wireshark group
sudo usermod -a -G wireshark YOUR_USER_NAME
Change the group  ownership of file dumpcap to wireshark
sudo chgrp wireshark/usr/bin/dumpcap
Change the mode of the file dumpcap to allow execution by the group wireshark
sudo chmod/usr/bin/dumpcap
Grant capabilities with setcap
sudo setcap cap_net_raw,cap_net_admin=eip /usr/bin/dumpcap
Verify the change
sudo getcap /usr/bin/dumpcap
At this point, you will need to log out, then back into Unity (Thanks for Jorge for pointing this out).
You should now be able to run Wireshark as a non-root user, just as long as that user is part on the wireshark group, everything should just work.

Thursday, 31 October 2013

Install Postgres & PgAdmin3 in UBUNTU

INSTALLATION
----------------------------------------------------------------------------------------------------------------------
STEP 1 : Before we install postgres,  perform a quick update of the apt-get repository :

apt-get update

(Type these commands in terminal)

STEP 2 : Once apt-get has updated go ahead and download Postgres :

sudo apt-get install postgresql postgresql-contrib


STEP 3 : Install pgadmin3 from UBUNTU Software Center
           
YOU ARE READY TO BEGIN....!!!
 ----------------------------------------------------------------------------------------------------------------------
USAGE :
  
STEP 4 : Open Terminal
  
 sudo su postgres

Enter your pc password

createdb database-name

psql database-name

create user kiran with password  'kiran';

(Add your own username & password in place of kiran)
 

STEP 5 : Open Another Terminal

pgadmin3 

 STEP 6 : Click Add a Connection to server(First Button in GUI)

  Name      : database-name
  Host        : localhost
  Port         : 5432
 Maintdb   : postgres
 username : kiran
 password : kiran
   
   YOU ARE DONE......!!!



 

Sunday, 27 October 2013

Install TASM in Ubuntu

Step 1 : First we will install an windows emulator called dosbox.

sudo apt-get install dosbox


Step 2 :

Download the packages for  


Create a directory for tasm in your home directory and extract files into that directory.If you are unable to extract type this in your terminal and try again

sudo apt-get install unrar


Install Java in Ubuntu

Just run the following command & you can easily get java installed..

REQUIREMENTS :
  • Internet Connection
  • Superuser Login

Command :

sudo apt-get install openjdk-7-jdk

Thursday, 24 October 2013

Easiest way to install NS2 in Ubuntu

For NS2 installation I browsed a lot on net but  found very lengthy time consuming procedures.Also some of them didnt worked out for me.Then I somehow succeded in installating NS2 through terminal with only two commands.Hereis a very simple procedure to install NS2 in Ubuntu.

REQUIREMENTS :
SuperUser Login
Internet Connection

PROCEDURE :

STEP 1: Installation of NS2

sudo apt-get install ns2

STEP 2: Installation of NAM(GUI)

 sudo apt-get install nam

Install Xampp in Ubuntu

* Step 1: Download
Xampp for linux : http://www.apachefriends.org/en/xampp-linux.html
(Check out which version you are downloading & respectively make changes in the version names in the following commands )
----------------------------------------------------------------------------
* Step 2: Installation
After downloading simply type in the following commands:

    Go to a Linux shell and login as the system administrator root:

    sudo su (or just su for lower versions than ubuntu 13.04)

    Change the permissions to the installer

    chmod 755 xampp-linux-1.8.3-1-installer.run

    Run the installer

    ./xampp-linux-1.8.3-1-installer.run

That's all. XAMPP is now installed below the /opt/lampp directory.
----------------------------------------------------------------------------
* Step 3: Start
To start XAMPP simply call this command:

/opt/lampp/lampp start

You should now see something like this on your screen:

Starting XAMPP 1.8.3...
LAMPP: Starting Apache...
LAMPP: Starting MySQL...
LAMPP started.

Ready. Apache and MySQL are running.


----------------------------------------------------------------------------
* Step 4: Test
OK, that was easy but how can you check that everything really works? Just type in the following URL at your favourite web browser:

http://localhost

Now you should see the start page of XAMPP containing some links to check the status of the installed software and some small programming examples.

----------------------------------------------------------------------------
* Step 5: Copy & read rights to htdocs folder :
sudo chmod 777 /opt/lampp/htdocs
chmod -R 777 /opt/lampp/htdocs/




      CONGRATS...Your Job Is Done...!!!!
----------------------------------------------------------------------------
Start  Xampp Service :
 /opt/lampp/lampp start

Stop  Xampp Service :
 /opt/lampp/lampp stop

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

For PhpMyAdmin: Type in browser
 localhost/phpmyadmin


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

Total Pageviews

DjKiRu Initative. Powered by Blogger.