jdbc:redshift://<endpoint>:<port>/<database>?user=<username>&password=<password>
import java.sql.*;
public class RedshiftExample {
public static void main(String[] args) {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
Class.forName("com.amazon.redshift.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:redshift://<endpoint>:<port>/<database>?user=<username>&password=<password>");
stmt = conn.createStatement();
rs = stmt.executeQuery("SELECT * FROM table");
while (rs.next()) {
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (rs != null) rs.close();
if (stmt != null) stmt.close();
if (conn != null) conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}