The simplest method for connecting to a MySQL database

Source: Internet
Author: User

The following articles mainly introduce the most simple method for connecting to the MySQL database. When we connect to the MySQL database, it is a headache for new users, the following is a combination of MySQL (the best combination of PHP and MySQL) databases.

Let's talk about how to connect to the MySQL database (the best combination with PHP.

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 ):
  4. Ocalhost/shangwu? User = root ";
  5. Connection con = DriverManager. getConnection (url );
  6. Statement SQL = con. createStatement ();
  7. ResultSet rs= SQL .exe cuteQuery ("select * from x ");
  8. While (rs. next ())
  9. Out. println (rs. getInt ("age "));
  10. %>
 

4: No configuration required.


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

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: 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.