Some work records on Java and databases in Ubuntu

Source: Internet
Author: User

I want to use a program to generate some test data and test which of the open source databases is suitable for our data warehouse project.

In fact, test data can be generated using a process, but I want to learn java, so I decided to implement it using a program. In addition, I first uninstalled the windows system that allows me to entertain as soon as I open my computer. Now it is pure Ubuntu.

First, record the Java Configuration:

First you need to download Java, this is a very simple process, the link here: I have a 64-bit system, so I chose a 64-bit gz package. After the download, You can decompress the package to any directory. Then you only need to configure these environment variables: vi. bashrc (note that it is in the current user's home directory), and then add the following words at the end of the file:

export JAVA_HOME=/home/wings/software/jdk1.7.0_21export JRE_HOME=${JAVA_HOME}/jreexport CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/libexport PATH=${JAVA_HOME}/bin:$PATH

Run the following command after saving:

source .bashrc

Enter java-version in terminal. if the version information is displayed, the installation is successful. If you are not sure, write hello, world.

The following is eclipse, which is super simple. Like in windows, This is a green installation-Free Software. Download the gz package and unzip it to a casual directory. Find this file: eclipse, then. /eclipse, just keep termial out of the box.

The database will be installed after these steps are completed. Mysql is easy to install. Open a termial and enter sudo apt-get install mysql-server. It will be installed automatically, and you will be asked to enter the root password during installation. The subsequent settings can be modified in the mysql configuration file, and you do not need to do anything before. If you really need to do anything, there will be a lot of google.

Install the jdbc driver at /. Download the gz package across platforms. After downloading the package, decompress the package to any directory. You only need to add the jar package to build path for future eclipse programming.

Attach the simple connection test code I wrote:

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();        }    }}

This experiment will continue in the future, and I will continue to record it. I hope that what I wrote today will be helpful to beginners like me.

Ps there is also a pitfall here. After I reinstall the system, I always remind me "there is no file or directory" when I follow the above steps and enter the java-version ", after the du Niang (not the name of the person) to know the missing package, record: sudo apt-get install ia32-libs.

  • 1
  • 2
  • Next Page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.