- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在开发通过 Redshift JDBC41 驱动程序版本 1.1.2.0002 连接到 AWS Redshift 实例的应用程序
当我使用 main(.)
方法运行应用程序时一切正常,但是当我尝试从单元测试(TestNG 和 Junit)获取连接时 - 在 DataSource 初始化时出现异常。这是 Redshift 客户端类:
import com.amazon.redshift.jdbc41.DataSource;
import com.mycompany.common.config.PropertiesHelper;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;
/**
*/
public class RedshiftDBClient {
private static final Logger logger = LogManager.getLogger(RedshiftDBClient.class);
private static RedshiftDBClient instance;
private DataSource dataSource;
private Properties properties;
private RedshiftDBClient() {
}
private void initDataSource() throws IOException {
properties = PropertiesHelper.getProperties();
dataSource = new DataSource();
dataSource.setUserID(properties.getProperty("rs.db.username"));
dataSource.setPassword(properties.getProperty("rs.db.password"));
dataSource.setURL(properties.getProperty("rs.db.url"));
}
public static synchronized RedshiftDBClient getInstance() {
if (instance == null) {
instance = new RedshiftDBClient();
}
return instance;
}
private DataSource getDataSource() throws IOException {
if (dataSource == null) {
initDataSource();
}
return dataSource;
}
public Connection getConnection() throws SQLException, IOException {
return getDataSource().getConnection();
}
}
这是我遇到的错误:
java.lang.ClassCastException: com.amazon.redshift.jdbc41.Driver cannot be cast to com.amazon.dsi.core.interfaces.IDriver
at com.amazon.dsi.core.impl.DSIDriverFactory.createDriver(Unknown Source)
at com.amazon.jdbc.common.AbstractDataSource.doInitialize(Unknown Source)
at com.amazon.jdbc.common.AbstractDataSource.getSimbaConnection(Unknown Source)
at com.amazon.jdbc.common.AbstractDataSource.getConnection(Unknown Source)
at com.mycompany.util.RedshiftDBClient.getConnection(RedshiftDBClient.java:60)
at com.mycompany.model.redshift.MatchSummaryModel.save(MatchSummaryModel.java:37)
at com.mycompany.thrift_gen.matchmaking.MatchmakingServiceHandler.ReportMatchResults(MatchmakingServiceHandler.java:59)
at com.mycompany.thrift_gen.matchmaking.MatchmakingClientProxy$Processor$ReportMatchResults.getResult(MatchmakingClientProxy.java:499)
at com.mycompany.thrift_gen.matchmaking.MatchmakingClientProxy$Processor$ReportMatchResults.getResult(MatchmakingClientProxy.java:484)
at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:39)
at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:39)
at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:285)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
11:23:55.276 [pool-2-thread-1] ERROR com.mycompany.thrift_gen.matchmaking.MatchmakingServiceHandler - Database exception
java.sql.SQLException: Error creating Driver, Driver class name incorrect.
at com.amazon.jdbc.common.AbstractDataSource.doInitialize(Unknown Source) ~[RedshiftJDBC41-1.1.2.0002.jar:RedshiftJDBC_1.1.2.0002]
at com.amazon.jdbc.common.AbstractDataSource.getSimbaConnection(Unknown Source) ~[RedshiftJDBC41-1.1.2.0002.jar:RedshiftJDBC_1.1.2.0002]
at com.amazon.jdbc.common.AbstractDataSource.getConnection(Unknown Source) ~[RedshiftJDBC41-1.1.2.0002.jar:RedshiftJDBC_1.1.2.0002]
at com.mycompany.util.RedshiftDBClient.getConnection(RedshiftDBClient.java:60) ~[classes/:?]
at com.mycompany.model.redshift.MatchSummaryModel.save(MatchSummaryModel.java:37) ~[classes/:?]
at com.mycompany.thrift_gen.matchmaking.MatchmakingServiceHandler.ReportMatchResults(MatchmakingServiceHandler.java:59) [classes/:?]
at com.mycompany.thrift_gen.matchmaking.MatchmakingClientProxy$Processor$ReportMatchResults.getResult(MatchmakingClientProxy.java:499) [classes/:?]
at com.mycompany.thrift_gen.matchmaking.MatchmakingClientProxy$Processor$ReportMatchResults.getResult(MatchmakingClientProxy.java:484) [classes/:?]
at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:39) [libthrift-0.9.2.jar:0.9.2]
at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:39) [libthrift-0.9.2.jar:0.9.2]
at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:285) [libthrift-0.9.2.jar:0.9.2]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_45]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_45]
Caused by: com.amazon.support.exceptions.GeneralException: Error creating Driver, Driver class name incorrect.
at com.amazon.dsi.core.impl.DSIDriverFactory.createDriver(Unknown Source) ~[RedshiftJDBC41-1.1.2.0002.jar:RedshiftJDBC_1.1.2.0002]
... 14 more
我唯一能想到的是类路径/类加载器搞砸了。
最佳答案
问题是因为我在类路径中有 Postgres JDBC 驱动程序。 Redshift JDBC 驱动程序实际上是 Postgres JDBC 驱动程序,带有一些额外的类并且可能进行了一些重构。我删除了 Redshift 驱动程序并使用 Postgres 驱动程序访问两个数据库,这解决了问题。
关于java - Redshift JDBC41 驱动初始化异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31011380/
我们可以直接将一张表从一个 Redshift 集群复制到另一个 Redshift 集群吗? 我知道可以使用 s3 作为临时存储来实现表复制(即从第一个集群卸载到 s3,然后从 s3 复制到另一个集群)
我在 AWS Redshift 集群中执行了以下操作以从 S3 读取 Parquet 文件。 create external schema s3_external_schema from data c
我在 AWS Redshift 集群中执行了以下操作以从 S3 读取 Parquet 文件。 create external schema s3_external_schema from data c
在 Amazon Redshift 中创建数据表时,您可以指定各种 encodings,例如 MOSTLY32 或 BYTEDICT 或 LZO。这些是在磁盘上存储列值时使用的压缩。 我想知道我选择的
我在 s3 中有一个压缩文件。我想将它插入到 RedShift 数据库中。我的研究发现做到这一点的唯一方法是启动一个 ec2 实例。将文件移到那里,解压缩,然后将其发送回 S3。然后将其插入到我的 R
为了在 Multi-Tenancy 维度 DW 中处理特定对象的自定义字段,我创建了 Redshift 不太喜欢的超宽非规范化维度表(数百列,列的硬编码限制);)。 user1|attr1|attr2
Redshift 文档将时间序列表确定为最佳实践: http://docs.aws.amazon.com/redshift/latest/dg/c_best-practices-time-series
我正在使用 redshift 的 COPY 命令从 S3 复制 json 数据。 表定义如下: CREATE TABLE my_raw ( id BIGINT IDENTITY(1,1), ... .
如何获取导出的键(数据库元数据)。即使 redshift 不支持外键和主键,我也可以在系统表中看到它们。这里的问题是在系统表中,外键的多列作为数组存在于一列中(尽管redshift不支持数组)。是否可
我正在寻找一种创建 Redshift 查询的方法,该查询将从每天生成的表中检索数据。我们集群中的表具有以下形式: event_table_2016_06_14 event_table_2016_06_
在 Redshift 中,当我们将结果导入 TABLEAU 时,我们试图为从查询返回的列提供更有意义的别名,问题是 RedShift 将所有字母转换为小写字母,即从“事件日期” ” 然后它返回“事件日
据我了解,Redshift 是为性能而不是可用性而构建的。文档 https://aws.amazon.com/redshift/faqs/建议一旦任何一个节点宕机,整个集群都会宕机,直到该节点恢复。在
我试图找出与中止查询相关的原因/错误,其中可以从 STL_query 表中找到中止的查询。我为此使用了 STL_errors,但发现错误上下文与 process id 相关,而不是特定的查询 id。有
我们正在使用 AWS Redshift DB 并希望创建一个在线复制(这样也可以完全更新更改)? 原因是我们希望为我们的一个部门提供一个单独的环境来运行他们自己的查询,因为他们可能会“发疯”并做一些
我在使用 DataGrip 的 Redshift 集群上运行查询需要超过 10 个小时才能运行,不幸的是,这些查询经常失败。唉,DataGrip 与数据库的连接保持的时间不够长,我无法看到查询失败的错
我正在对 redshift 中的一些查询进行基准测试,以便我可以对我对表所做的更改进行一些智能说明,例如添加编码和运行 vacuum。我可以查询stl_query带有 LIKE 子句的表来查找我感兴趣
删除表后,redshift 是否回收可用磁盘空间,或者我们是否需要运行 vaccum。 最佳答案 drop table 释放空间。 如果您正在对表的行进行删除操作,那么您应该触发 vaccumm de
有没有办法在 Amazon Redshift 中计算具有固定窗口大小的加权移动平均值?更详细地说,给定一个带有日期列和值列的表,对于每个日期计算指定大小窗口的加权平均值,并在辅助表中指定权重。 到目前
我注意到第一次在 RedShift 上运行查询需要 3-10 秒。当我再次运行相同的查询时,即使在 WHERE 条件中使用不同的参数,它也会运行得很快(0.2 秒)。 我正在谈论的查询在一个约 1M
我明白 the COPY command非常有效地导入大量数据。但是使用 the INSERT command 将数据从一个表复制到另一个表是慢的。有没有更有效的方法将数据从一个表复制到另一个表?或者
我是一名优秀的程序员,十分优秀!