我想使用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)