How to connect mysql with Basex?

泪湿孤枕 提交于 2021-02-04 14:07:52

问题


I have a application with Mysql as Database which is using a lot XML/HTML. I would like to process mysql data in BaseX and update database through it. Is there any simple way to connect Database? I checked http://docs.basex.org/wiki/SQL but it is not working. Can you please give me simple example what I have to do to connect? I got error An SQL exception occurred: 'No suitable driver found for jdbc:mysql://localhost:3306/test' here is my code:

let $conn := sql:connect("jdbc:mysql://localhost:3306/test")
return sql:execute($conn, "SELECT * FROM coffees WHERE price < 10")

Where should I put mysql jdbc connector (mysql-connector-java-5.1.34-bin.jar) in basex to make it work? Thanks


回答1:


First download latest version of mysql jdbc driver. Here is 5.1.36, inside this, there is .jar file, extract jar file and put in BaseX installation folder's lib directory. In windows it is

C:\Program Files (x86)\BaseX\lib

Restart the server or GUI. for GUI you should close everything, better to open from bin directory's basexgui

sql:init("com.mysql.jdbc.Driver"),
let $con := sql:connect('jdbc:mysql://localhost:3306/DB_NAME', 'DB_USER', 'DB_PASSWORD')
return sql:execute($con, "select version()")

for detail queries BaseX documentation



来源:https://stackoverflow.com/questions/27186890/how-to-connect-mysql-with-basex

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!