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
- <%
- Class. forName ("org. gjt. mm. MySQL (the best combination with PHP). Driver"). newInstance ();
- String url = "jdbc: MySQL (the best combination with PHP): // localhost/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.
The above content describes the simplest method for connecting to the MySQL database. I hope it will help you in this regard.