-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckDB.java
More file actions
22 lines (21 loc) · 940 Bytes
/
Copy pathCheckDB.java
File metadata and controls
22 lines (21 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.sql.*;
public class CheckDB {
public static void main(String[] args) throws Exception {
Connection conn = DriverManager.getConnection("jdbc:sqlite:mundial2026.db");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT COUNT(*) as c FROM GRUPO");
rs.next();
System.out.println("Grupos: " + rs.getInt("c"));
rs = stmt.executeQuery("SELECT COUNT(*) as c FROM EQUIPO");
rs.next();
System.out.println("Equipos: " + rs.getInt("c"));
rs = stmt.executeQuery("SELECT COUNT(*) as c FROM PARTIDO");
rs.next();
System.out.println("Partidos: " + rs.getInt("c"));
rs = stmt.executeQuery("SELECT * FROM EQUIPO LIMIT 5");
while (rs.next()) {
System.out.println(" " + rs.getInt("id") + ": " + rs.getString("nombre") + " (" + rs.getString("pais") + ")");
}
conn.close();
}
}