java mysql

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class FetchValueClass {

	static final String URL = "jdbc:mysql://localhost/cm";
	static final String USERNAME = "user";
	static final String PASSWORD = "pass";

	public static void main(String[] args){

		String sql = "SELECT * FROM music;";

		try ( Connection connection = DriverManager.getConnection(URL, USERNAME, PASSWORD);
			PreparedStatement statement = connection.prepareStatement(sql); ){

			ResultSet result = statement.executeQuery();

			result.next();
			System.out.println(result.getString(1));
			System.out.println(result.getString(2));
			System.out.println(result.getString(3));
			System.out.println(result.getString("id"));
			System.out.println(result.getString("name"));
			System.out.println(result.getString("title"));

			System.out.println("");

			result.next();
			System.out.println(result.getString(1));
			System.out.println(result.getString(2));
			System.out.println(result.getString(3));
			System.out.println(result.getString("id"));
			System.out.println(result.getString("name"));
			System.out.println(result.getString("title"));

		} catch(SQLException e){
			e.printStackTrace();
		}
	}
}