mysql - 来自 BaseX 的 xquery 错误:[sql:init] 找不到驱动程序:com.mysql.jdbc.Driver
问题描述
JDBC
我在下面缺少哪个特定驱动程序?
nicholas $
nicholas $ basex mysql.xq
Stopped at /home/nicholas/flwor/mysql.xq, 3/9:
[sql:init] Could not find driver: com.mysql.jdbc.Driver
nicholas $
nicholas $ cat mysql.xq
xquery version "3.0";
sql:init("com.mysql.jdbc.Driver"),
let $con := sql:connect("jdbc:mysql://localhost:3306/northwind")
return sql:execute($con, "SELECT first_name FROM customers LIMIT 3;")
nicholas $
nicholas $ mysql -h localhost -P 3306 --protocol=tcp -u user -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2901
Server version: 8.0.21 MySQL Community Server - GPL
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> SELECT first_name FROM northwind.customers LIMIT 3;
+------------+
| first_name |
+------------+
| Alexander |
| Amritansh |
| Andre |
+------------+
3 rows in set (0.00 sec)
mysql>
我已经尝试通过在 Ubuntu 上查看来安装一些JDBC
结果apt
,但看起来我可能需要将它们连接起来BaseX
以便它们被拾取。
而且,顺便说一句,我可能需要发送用户和密码来运行上述查询,具体到MySQL
?
解决方案
您需要安装适当的 JAR,并将其添加到您的类路径中。
使用打包的驱动程序:
sudo apt install libmariadb-java
编辑您的mysql.xq
文件以加载org.mariadb.jdbc.Driver
而不是com.mysql.jdbc.Driver
,并basex
使用以下命令运行:
JAVA_CLASSPATH=/usr/share/java/mariadb-java-client.jar basex
可以通过各种方式提供身份验证信息,例如使用连接字符串中的参数和/或 MariaDB/MySQL 客户端配置文件中的信息。
推荐阅读
- android - java.lang.NullPointerException:您无法在 getActivity() 返回 null 的尚未附加的 View 或 Fragment 上开始加载
- python - 寻找提取子字符串
- variables - 如何动态调整 PySpark 参数
- excel - 如何将公式嵌套到一个公式中?
- javascript - 如何访问 API 内部的第二层
- vue.js - 元素 UI 不显示来自 fetch-suggestion 的数据
Vue.js - javascript - 从源“website_url”访问“url”处的 XMLHttpRequest 已被 CORS 策略 PHP Javascript 为什么阻止?
- c++ - Gradle 构建的带有 Boost Lib 的 C++ 示例项目
- reactjs - Material-UI菜单打开后抖动
- javascript - 允许单词列表