package com.roshka.jdbc; import java.sql.*; public class Q11 { public static void main( String [] args ) { String url = "jdbc:postgresql://localhost:5433/testdb"; String user = "test"; String password = "pqntslc"; try { /* QUERY * SELECT name * FROM courses * WHERE EXTRACT('week' FROM start_date) * - EXTRACT('week' FROM CURRENT_DATE) = 1; * */ Connection connection = DriverManager.getConnection(url, user,password); System.out.println("estoy conectado a la base de datos"); Statement st = connection.createStatement(); String query = "SELECT name " + "FROM courses " + "WHERE EXTRACT('week' FROM start_date) " + "- EXTRACT('week' FROM CURRENT_DATE) = 1;"; ResultSet rs = st.executeQuery(query); while(rs.next() ) { String name = rs.getString("name"); System.out.println(name); } }catch(SQLException e) { e.printStackTrace();; } } }