Home Database Mysql Tutorial Ubuntu下有关Java和数据库的一些工作记录(一)_MySQL

Ubuntu下有关Java和数据库的一些工作记录(一)_MySQL

Jun 01, 2016 pm 01:34 PM
java windows storehouse database

Ubuntu

bitsCN.com

      我希望用程序生成一些测试数据,测试一下开源数据库中哪个比较适合我们的数据仓库项目,于是有了这篇随笔。

      其实测试数据可以用过程生成,但是我想学学java因此决定用程序实现。而且我先在把windows这个让我一打开电脑就想娱乐的系统卸载了,现在纯Ubuntu。

      先记录下Java的配置:

      首先需要下载Java,这是一个很简单的过程,链接在这里:http://www.oracle.com/technetwork/java/javase/downloads/index.html 。我的是64位系统,因此选择了64位的gz包。下载好以后随便解压到哪个目录底下都是可以的。然后只需要配置这么几个环境变量就可以了:vi .bashrc(注意是在当前用户的家目录下),然后在文件的最后加上这么几句话:

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
Copy after login

      保存以后执行这个命令:

source .bashrc
Copy after login

       接下来在terminal中输入:java -version,如果出现版本信息,那么就安装成功了,如果不确定可以写个hello,world试试。

      下面就是eclipse了,这个超级简单,和windows下面一样,这是个绿色免安装软件,下载gz包以后解压到一个随便的目录下面,找到这个文件:eclipse,然后./eclipse,保持termial不要关闭就好了。

      这些都好了以后就要安装数据库了。mysql很好装,打开一个termial,输入:sudo apt-get install mysql-server。自动会安装,而且安装的时候会让你输入root密码,之后的设置可以在mysql的配置文件中修改,不需要在之前做什么,如果真的需要做什么,google一下会有很多。 

      安装好之后就需要把jdbc驱动装上,下载地址在这里:http://dev.mysql.com/downloads/connector/j/。下载gz包,跨平台的。下载好以后解压到一个任意目录去,在以后eclipse编程的时候只需要在build path里加入这个jar包就可以了。

      附上我写的简单的连接测试代码:

      

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

         时间不早了,睡觉去,祝大家儿童节快乐。以后这个实验会继续进行,我也会继续记录。希望今天写的会对向我一样的初学者有些帮助。

     

bitsCN.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1677
14
PHP Tutorial
1279
29
C# Tutorial
1257
24
Python development_python installation Python development_python installation May 07, 2025 pm 04:33 PM

Python can run on a variety of platforms, including our common ones: Windows, Unix, Linux, and Macintosh. This article will introduce in detail the process of installing Python in Windows operating system. My operating system is Windows 7, 32-bit version. When installing Python, we can choose to install it from the source code or select the already compiled binary version for installation. I chose the latter here. Step 1 Download the installation package. We download the installation package of Python from the official Python website: http://www.python.org. The version I selected is: python-3.3.2.msi click to download, I

10 latest tools for web developers 10 latest tools for web developers May 07, 2025 pm 04:48 PM

Web development design is a promising career field. However, this industry also faces many challenges. As more businesses and brands turn to the online marketplace, web developers have the opportunity to demonstrate their skills and succeed in their careers. However, as demand for web development continues to grow, the number of developers is also increasing, resulting in increasingly fierce competition. But it’s exciting that if you have the talent and will, you can always find new ways to create unique designs and ideas. As a web developer, you may need to keep looking for new tools and resources. These new tools and resources not only make your job more convenient, but also improve the quality of your work, thus helping you win more business and customers. The trends of web development are constantly changing.

.NET Core Quick Start Tutorial 1. The beginning: Talking about .NET Core .NET Core Quick Start Tutorial 1. The beginning: Talking about .NET Core May 07, 2025 pm 04:54 PM

1. The Origin of .NETCore When talking about .NETCore, we must not mention its predecessor .NET. Java was in the limelight at that time, and Microsoft also favored Java. The Java virtual machine on the Windows platform was developed by Microsoft based on JVM standards. It is said to be the best performance Java virtual machine at that time. However, Microsoft has its own little abacus, trying to bundle Java with the Windows platform and add some Windows-specific features. Sun's dissatisfaction with this led to a breakdown of the relationship between the two parties, and Microsoft then launched .NET. .NET has borrowed many features of Java since its inception and gradually surpassed Java in language features and form development. Java in version 1.6

What's Happening with MongoDB? Exploring the Facts What's Happening with MongoDB? Exploring the Facts May 04, 2025 am 12:15 AM

MongoDB is still a powerful database solution. 1) It is known for its flexibility and scalability and is suitable for storing complex data structures. 2) Through reasonable indexing and query optimization, its performance can be improved. 3) Using aggregation framework and sharding technology, MongoDB applications can be further optimized and extended.

How to return the previous version of win11 win11 system rollback operation guide How to return the previous version of win11 win11 system rollback operation guide May 07, 2025 pm 04:21 PM

Starting the rollback function on Windows 11 must be performed within 10 days after the upgrade. The steps are as follows: 1. Open "Settings", 2. Enter "System", 3. Find the "Recover" option, 4. Start rollback, 5. Confirm the rollback. After rollback, you need to pay attention to data backup, software compatibility and driver updates.

Redis: A Comparison to Traditional Database Servers Redis: A Comparison to Traditional Database Servers May 07, 2025 am 12:09 AM

Redis is superior to traditional databases in high concurrency and low latency scenarios, but is not suitable for complex queries and transaction processing. 1.Redis uses memory storage, fast read and write speed, suitable for high concurrency and low latency requirements. 2. Traditional databases are based on disk, support complex queries and transaction processing, and have strong data consistency and persistence. 3. Redis is suitable as a supplement or substitute for traditional databases, but it needs to be selected according to specific business needs.

Java Platform Independence: Advantages for web applications Java Platform Independence: Advantages for web applications May 09, 2025 am 12:08 AM

Java'splatformindependencebenefitswebapplicationsbyallowingcodetorunonanysystemwithaJVM,simplifyingdeploymentandscaling.Itenables:1)easydeploymentacrossdifferentservers,2)seamlessscalingacrosscloudplatforms,and3)consistentdevelopmenttodeploymentproce

Is Redis Primarily a Database? Is Redis Primarily a Database? May 05, 2025 am 12:07 AM

Redis is primarily a database, but it is more than just a database. 1. As a database, Redis supports persistence and is suitable for high-performance needs. 2. As a cache, Redis improves application response speed. 3. As a message broker, Redis supports publish-subscribe mode, suitable for real-time communication.

See all articles