小编Nic*_*ick的帖子

使用JDBC连接AWS Redshift

我想使用JDBC连接数据并将数据插入到我的Amazon Redshift表中.我编写了以下代码,但在Class.forName行继续收到错误

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

public class RedShiftDataEmitter {
    static final String redshiftUrl = "jdbc:redshift://xxxxxxxxx:5439/xxxxxx";
    static final String masterUsername = "xxxxxxx";
    static final String password = "xxxxxxx";

    public static void main(String[] args) {
        Connection connection = null;
        Statement statement = null;

        try {
            Class.forName("com.amazon.redshift.jdbc41.Driver");
            Properties properties = new Properties();
            properties.setProperty("user", masterUsername);
            properties.setProperty("password", password);
            connection = DriverManager.getConnection(redshiftUrl, properties);
            // Further code to follow
        } catch(ClassNotFoundException cnfe) {
            cnfe.printStackTrace();
        } catch (SQLException sqle) {
            sqle.printStackTrace(); …
Run Code Online (Sandbox Code Playgroud)

java jdbc amazon-web-services

2
推荐指数
1
解决办法
6418
查看次数

标签 统计

amazon-web-services ×1

java ×1

jdbc ×1