MySQL-based JDBC development in Ubuntu

Source: Internet
Author: User
Installation environment: UbuntuLinux1. Install JDK2 first. Install MySQL JDBC driver Connector/J (1) Search Connector/J (2) in the new Ubuntu software management package and install JDK2 (3) find the mysql-connector-java-n.n.n file in ubuntu and put it under/usr/lib/java (?), Install it and copy it to your java installation directory.

Installation environment: Ubuntu Linux

1. Install JDK first

2. Install MySQL JDBC driver Connector/J

(1) Search for Connector/J in the new software management package of Ubuntu

(2) Find and install

(3) Find the mysql-connector-java-n.n.n file under ubuntu and put it under/usr/lib/java (?), Install it and copy it to your java installation directory. java under ubuntu is only a link file, so you should obtain/usr/lib/jvm/java-6-sun/jre/lib/ext

3. When performing a jdbc link, you must first load the Connector/J driver statement: Class. forName ("com. mysql. jdbc. Driver"). getInstance ();

4. Create a link: Connection con = DriverManager. getConnection (url, username, password );

The url type is as follows:

Jdbc: mysql: // host name/Database Name? CharacterEncoding = utf8

Username is the user name that can log on to the database and perform operations on it. It is set in mysql.

Password is the login password corresponding to the user name.

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.