问题描述
下面我是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>
我通过在Ubuntu上浏览JDBC
tried安装了一些apt
的结果,但看来我可能需要connect来安装{{1 }},以便将它们捡起来。
而且,偶然地,我可能需要发送用户名和密码来运行上述查询,specific至BaseX
?
解决方法
您需要安装适当的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客户端配置文件中的信息。