Some work records on Java and databases in Ubuntu (1) _ MySQL

Source: Internet
Author: User
Some work records on Java and databases in Ubuntu (1) Ubuntu

BitsCN.com

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: http://www.oracle.com/technetwork/java/javase/downloads/index.html. 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 http://dev.mysql.com/downloads/connector/j /. 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();        }    }}

It's not too early to go to bed. I wish you a happy Children's Day. 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.

BitsCN.com

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: info-contact@alibabacloud.com 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.