In this tutorial provides an example of how to create a simple JDBC application. This will show you how to open a database connection, execute a SQL query or statements and display the results.
For connecting java application with the mysql database, you need to follow 5 steps to perform database connectivity.
In this example we are using MySql as the database. So we need to know following information for the mysql database:
- Driver class: The driver class for the mysql database is com.mysql.jdbc.Driver.
- Connection URL: The connection URL for the mysql database is jdbc:mysql://localhost:3306/student where jdbc is the API, mysql is the database, localhost is the server name on which mysql is running, we may also use IP address, 3306 is the port number and student is the database name. We may use any database, in such case, you need to replace the student with your database name.
- Username: The default username for the mysql database is root.
- Password: Password is given by the user at the time of installing the mysql database. In this example, we are going to use root as the password.
Let's take one example.
If you have any kind of question about any post, Feel free to ask.You can simply drop a comment below post. Your feedback and suggestions will be highly appreciated. ConversionConversion EmoticonEmoticon