1 // Create a variable for the connection string.
2 String connectionUrl = "jdbc:sqlserver://sql303.epizy.com:3306;databaseName=epiz_237047xx_people;user=xxx;password=xxx";
3 try {
4 Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
5 System.out.println("ya");
6 } catch (ClassNotFoundException e1) {
7 e1.printStackTrace();
8 }
9
10 try {
11 Connection con = DriverManager.getConnection(connectionUrl);
12 Statement stmt = con.createStatement();
13 String SQL = "SELECT * FROM people";
14 ResultSet rs = stmt.executeQuery(SQL);
15
16 // Iterate through the data in the result set and display it.
17 while (rs.next()) {
18 System.out.println(rs.getString(1) + " " + rs.getString(2));
19 }
20 }
21 // Handle any errors that may have occurred.
22 catch (SQLException e) {
23 e.printStackTrace();
24 }
25}
26