use mysql in java program 1

use mysql in java program

// For windows
java -cp .;/path/to/mysql-connector-java-8.0.{xx}.jar JDBCClassToRun
// For macOS / Unixes
java -cp .:/path/to/mysql-connector-java-8.0.{xx}.jar JDBCClassToRun

Here is what the above code is Doing:
1. We’re creating a connection to the database.
2. We’re creating a statement object.
3. We’re executing a query, which returns a result set.
4. We’re iterating over the result set, printing out the artist ID and name for each row.
5. We’re closing the connection.

Similar Posts