The simplest solution for connecting to the MySQL database

Source: Internet
Author: User

This article mainly introduces you to the simplest method of connecting to the MySQL database. We all know that connecting to the MySQL database is difficult for new users, the following article describes how to connect to a MySQL (the best combination of PHP and MySQL) database.

1: Download a driver, such as mm. MySQL (the best combination with PHP)-2.0.4-bin. jar.

2: place it under the common \ lib directory

3: Test

 
 
  1. <%
  2. Class. forName ("org. gjt. mm. MySQL (the best combination with PHP). Driver"). newInstance ();
  3. String url = "jdbc: MySQL (the best combination with PHP): // localhost/shangwu? User = root ";
  4. Connection con = DriverManager. getConnection (url );
  5. Statement SQL = con. createStatement ();
  6. ResultSet rs= SQL .exe cuteQuery ("select * from x ");
  7. While (rs. next ())
  8. Out. println (rs. getInt ("age "));
  9. %>

4: No configuration required.

The above content introduces the simplest method for connecting to the MySQL database.

The above content describes the simplest method for connecting to the MySQL database. I hope it will help you in this regard.

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.