我使用的是Java8、Spark 2.1.1、Ignite2.5和BoneCP 0.8.0
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>ignite-tester</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<java.version>1.8</java.version>
<kafka.version>0.10.1.2.6.2.0-205</kafka.version>
<spark.version>2.1.1.2.6.2.0-205</spark.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>spark.IgniteTester</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-core</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>com.jolbox</groupId>
<artifactId>bonecp</artifactId>
<version>0.8.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql-kafka-0-10_2.11</artifactId>
<version>${spark.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.11</artifactId>
<version>${spark.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-streaming_2.11</artifactId>
<version>${spark.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
public static void main(String[] args) {
try {
Class.forName("org.apache.ignite.IgniteJdbcThinDriver").newInstance();
BoneCPConfig config = new BoneCPConfig();
config.setJdbcUrl("jdbc:ignite:thin://myhost:10840;user=myusername;password=mypassword");
pool = new BoneCP(config);
} catch (Exception e) {
logger.error("could not load Ignite driver", e);
return;
}
}
结果出现以下异常:
ERROR IgniteTester: could not load Ignite driver
java.sql.SQLException: Unable to open a test connection to the given database. JDBC url = jdbc:ignite:thin://myhost:10840;user=myusername;password=mypassword, username = null. Terminating connection pool (set lazyInit to true if you expect to start your database after your app). Original Exception: ------
java.sql.SQLException: No suitable driver found for jdbc:ignite:thin://myhost:10840;user=myusername;password=mypassword
at java.sql.DriverManager.getConnection(DriverManager.java:689)
at java.sql.DriverManager.getConnection(DriverManager.java:208)
at com.jolbox.bonecp.BoneCP.obtainRawInternalConnection(BoneCP.java:361)
at com.jolbox.bonecp.BoneCP.<init>(BoneCP.java:416)
at spark.IgniteTester.main(IgniteTester.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:751)
at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:187)
at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:212)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:126)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.jolbox.bonecp.PoolUtil.generateSQLException(PoolUtil.java:192)
at com.jolbox.bonecp.BoneCP.<init>(BoneCP.java:422)
at spark.IgniteTester.main(IgniteTester.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:751)
at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:187)
at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:212)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:126)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
Caused by: java.sql.SQLException: No suitable driver found for jdbc:ignite:thin://myhost:10840;user=myusername;password=mypassword
at java.sql.DriverManager.getConnection(DriverManager.java:689)
at java.sql.DriverManager.getConnection(DriverManager.java:208)
at com.jolbox.bonecp.BoneCP.obtainRawInternalConnection(BoneCP.java:361)
at com.jolbox.bonecp.BoneCP.<init>(BoneCP.java:416)
... 10 more
提交脚本如下所示:
spark-submit \
--class spark.IgniteTester \
--master yarn \
--deploy-mode master \
--driver-memory 1g \
--executor-cores 1 \
--num-executors 1 \
--executor-memory 1664mb \
ignite-tester.jar
当使用“本地”Spark实例时,它使用think JDBC驱动程序连接到Ignite。有什么想法吗?
谁会最终到达这里--对我有效的是上面的建议,放弃BoneCP作为数据库连接池,使用单个数据库连接:
Class.forName("org.apache.ignite.IgniteJdbcThinDriver");
Connection conn = DriverManager.getConnection("jdbc:ignite:thin://myhost:10840;user=myusername;password=mypassword");
ResultSet rs = conn.prepareStatement("SELECT * FROM MY_TABLE").executeQuery());
如果您仔细考虑一下,根据我的理解,只使用单个DB连接是非常有意义的--Spark无论如何都是在“单个”线程模型中运行代码的,所以拥有多于单个连接并没有真正的好处。希望这能有所帮助。
我们有一个使用Oracle 19.3数据库运行的项目,以及一个使用Oracle 19.3 JDBC驱动程序(在Maven Central上可用)的Java应用程序。在带有JRE1.8的Windows上,一切都很好,但当我运行在构建服务器上或在带有OpenJDK11.0.3的WSL Ubuntu中时,它拒绝连接到数据库。具体地说: 如果切换到18.3JDBC驱动程序,在这两种环境中一切都很好;如果我
我将DataGrip配置为使用spark安装文件夹中的JDBC库。
我想从Linux实例使用TLS1.2连接到我的数据库实例,但我无法这样做。我使用以下配置: < Li > Java JDK:Amazon corretto open JDK版本:" 1.8.0_252" < li>JDBC驱动程序:Microsoft SQL server MSSQL-JDBC:8 . 2 . 2 . JRE 8 < li >连接字符串:JDBC:SQL server://[我的数
问题内容: 我目前正在为大学的一个班级做项目。我正在学习有关连接和操作数据库的信息,我们正在使用Microsoft .accdb文件。 这是我到目前为止所拥有的。 当寻找“ sun.jdbc.odbc.JdbcOdbcDriver”时,我得到以下输出。 似乎很容易解决。看来我想念司机或类似的东西。但是,我很难找到解决方法。JDK随附驱动程序吗?我需要单独下载吗?是否取决于我的操作系统?(Mac O
问题内容: 我已经尝试了几乎所有可以找到的一切,如果有人能够帮助我,我将永远感激不已(在我的时间里,我有更多的空闲时间)。 基本上,我在Tomcat 7.0中有一个错误(都是在Eclipse中运行并通过startup.bat运行时),该错误表示一旦动态Web应用程序开始访问数据,就会出现此错误: 我的tomcat \ lib目录中有sqljdbc4.jar文件。我也尝试过将它放在我的WEB-INF
我试图建立一个SSL连接到赛贝斯ASE 15.7使用JDBC驱动程序没有运气。我尝试了以下选项: > 使用JTDS 1.25驱动程序(jtds-1.2.5.jar) 使用以下连接字符串: 我收到 使用jconnect4(jconn4.jar) 使用以下连接字符串: jdbc:sybase:Tds:host:port/dbname?ENABLE_SSL=true 我得到了