Ubuntu some of the Java and the database record (a)

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

      I hope the program to generate test data, test the open-source database which is suitable for the data warehouse of our projects, so this essay.

In fact, test data can be used to process, but I want to learn java therefore decided to use the program. And I first in the windows that made me open the computer to uninstall the entertainment system, now the pure Ubuntu.

      The first record of the Java configuration:

      First need to download the Java, this is a very simple process, link here: http://www.oracle.com/technetwork/java/javase/downloads/index.html . I is a 64 bit system, so the choice of 64 bit GZ package. Download after decompression under random which directory can be. Then you only need to configure these environment variables can be: VI.Bashrc (attention in the current user's home directory), and then at the end of the file with so few words:

export JAVA_HOME=/home/wings/software/jdk1.7.0_21
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

      After executing this command to save:

source .bashrc

      The next input in terminal: Java -version, if the version information, then installed successfully, if not sure can write an Hello, world.

Eclipse is the following, this super simple, and windows like below, this is a green free installation software, download the GZ package to extract a casual directory, find the file: Eclipse, then./eclipse, termial do not close enough.

      These are good will install the database. MySQL very good, open a termial, apt-get install mysql-server type: sudo. Automatic installation, and installation time will let you enter the root password, after the set can be modified in the MySQL configuration file, do not need to do anything before, if you really need to do, you will have a lot of Google.

      After installing the need to install the jdbc driver, download address here: http://dev.mysql.com/downloads/connector/j/. Download the GZ package, cross platform. Download after decompression to an arbitrary directories, after eclipse programming need to add in build path in the jar package can be.

      Enclosed I wrote a simple test code.:

     

import java.sql.*;
public class DBConnector
{
    static Connection conn;
    public static void main(String[] args)
    {
        try
        {
            Class.forName("com.mysql.jdbc.Driver");
            System.out.println("Load mysql driver success!");
        }
        catch(Exception err)
        {
            System.out.print("Load mysql driver failed!");
            err.getStackTrace();
        }
        try
        {
            conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "wings", null);
            System.out.println("Connect success!");
        }
        catch(Exception err)
        {
            System.out.println("Connect failed!");
            err.getStackTrace();
        }
    }
}

        Time is not early, go to bed, I wish you a happy children's day. The experiment will continue, I also will continue to record. Hope today write on to me some help beginners.

        PS there is a cheating place, after I reinstall the system, in accordance with the above steps, the input Java -version always remind me of the “ not the file or directory ”, the degrees Niang (not the name) before you know less of a package, were recorded in the: sudo apt-get install ia32-libs.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Gavin at December 07, 2013 - 11:12 AM