【发布时间】:2021-01-08 16:18:46
【问题描述】:
下面的missing我是哪个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>
我已经 tried 安装了一些 JDBC 的结果,这些结果是通过在 Ubuntu 上查看 apt 得到的,但看起来我可能需要 connect 那些使用 BaseX 的人,以便他们被选中。
顺便说一句,我可能需要发送用户和密码来运行上述查询,specific 到 MySQL?
【问题讨论】:
-
您需要在 BaseX 的类路径中安装 MySQL 驱动程序。最简单的方法是按照 BaseX SQL 模块文档中的说明进行操作。从他们提供的链接下载平台无关的驱动程序包,提取文件并将 jar 文件放在 BaseX lib 子目录中。对于用户/密码,请参阅 sql:connect 文档。
-
谢谢@chrisis,我会把它放到
lib目录中——只是在Ubuntu 上寻找它的位置。 -
不确定 Ubuntu 发行版是如何工作的。我一直使用 BaseX 下载页面的完整发行版,因为它拥有一切并且是最新版本。最好的猜测是在你的主目录下的 basex 目录中创建一个 lib 目录,并将驱动程序 jar 放在那里。仅基于将 jars 放在类路径上的该位置的完整发行版的猜测。
标签: mysql sql jdbc xquery basex