content: package com.example;
  
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.sql.Statement;
  
  public class Main {
      public static void main(String[] args) {
          String url = "jdbc:mysql://localhost:3307/db1";
          String user = "root";
          String password = "root";
  
          Connection connection = null;
          Statement statement = null;
          ResultSet resultSet = null;
  
          try {
              connection = DriverManager.getConnection(url, user, password);
              statement = connection.createStatement();
  
              resultSet = statement.executeQuery("SELECT * FROM db1.t1");
  
              while (resultSet.next()) {
                  int id = resultSet.getInt("id");
                  String name = resultSet.getString("name");
                  System.out.println("ID: " + id + ", Name: " + name);
              }
          } catch (SQLException e) {
              e.printStackTrace();
          } finally {
              // Close the result set, statement, and connection
              try {
                  if (resultSet != null) {
                      resultSet.close();
                  }
                  if (statement != null) {
                      statement.close();
                  }
                  if (connection != null) {
                      connection.close();
                  }
              } catch (SQLException e) {
                  e.printStackTrace();
              }
          }
      }
  }
  