Demo entry 6787661

Exercice 1

   

Submitted by anonymous on Apr 14, 2019 at 18:18
Language: Java. Code size: 516 Bytes.

public static void displayDepartment(Connection connexion) throws SQLException {
		Statement statement = connexion.createStatement();
		ResultSet resultat = statement.executeQuery("SELECT deptno, dname, loc FROM dept");

		while (resultat.next()) {
			int deptno = resultat.getInt("deptno");
			String dname = resultat.getString("dname");
			String loc = resultat.getString("loc");

			System.out.println("Department " + deptno + " is for " + dname + " and located in " + loc);
		}
		resultat.close();
	}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).