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
- <%
- Class. forName ("org. gjt. mm. MySQL (the best combination with PHP). Driver"). newInstance ();
- String url = "jdbc: MySQL (the best combination with PHP ):
- Ocalhost/shangwu? User = root ";
- Connection con = DriverManager. getConnection (url );
- Statement SQL = con. createStatement ();
- ResultSet rs= SQL .exe cuteQuery ("select * from x ");
- While (rs. next ())
- Out. println (rs. getInt ("age "));
- %>
4: No configuration required.
The above content introduces the simplest method for connecting to the MySQL database.