java - 连接到 Azure 数据库时出现 ClassNotFoundException

标签 java database azure mariadb classnotfoundexception

我正在尝试将 Java 应用程序连接到存储在云中的 Azure 数据库。运行时我不断收到 ClassNotFoundException

Class.forName("org.mariadb.jdbc");

我对 Java 有丰富的经验,但对于将 Java 应用程序连接到数据库还不熟悉。我已经下载并包含了

“mariadb-java-client-2.5.2-sources.jar”

在我的项目中。我还应该包含其他 jar 文件吗?如果不是,我还需要做什么来防止此错误发生?如果有帮助的话我正在使用 Eclipse。

谢谢

最佳答案

使用 Maven 依赖

<!-- https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client -->
<dependency>
    <groupId>org.mariadb.jdbc</groupId>
    <artifactId>mariadb-java-client</artifactId>
    <version>2.5.2</version>
</dependency>

关于java - 连接到 Azure 数据库时出现 ClassNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59056253/

相关文章:

java - 为什么首选 Java 类的接口(interface)?

Java 代码不等待扫描仪输入

.net - 金融市场开发商困境

database - 在 Microsoft Access 2010 中连接表

azure - Azure 中的平均内存工作集和内存工作集

java - 从 java.Server 中的 Url 下载图像返回 HTTP 响应代码 : 403 error. 如何使连接正常工作?

java - 如何在 SharedPreferences 中保存和检索日期

c++ - 两个类之间的共享方法

sql - 在 Azure Synapse 专用/无服务器 SQL 池中使用增量表

azure - CLI 响应未指定在 Azure ContainerApp 中选择什么类型的入口流量设置