[英]Unable to load driver: com.mysql.jdbc.Driver
I try to use Jasper to generate report in Laravel. 我尝试使用Jasper在Laravel中生成报告。 It's work perfect if I didn't use database, if I add database to get data from mysql database he gives me an error "Unable to load driver: com.mysql.jdbc.Driver".
如果我不使用数据库,那是完美的工作,如果我添加数据库以从mysql数据库获取数据,他会给我一个错误“无法加载驱动程序:com.mysql.jdbc.Driver”。 I install JDBC Connector and Setup ODBC connection to local mysql server:
我安装了JDBC连接器,并建立了与本地mysql服务器的ODBC连接:
Also I setup CLASSPATH to MySQL connector: 我也将CLASSPATH设置为MySQL连接器:
Because laravel print me that have some error to generate pdf with database connection I change it to print output command and ran it in terminal and he gives me an error that "Unable to load driver: com.mysql.jdbc.Driver", see next picture: 因为laravel打印我在通过数据库连接生成pdf时出现一些错误,所以我将其更改为打印输出命令并在终端中运行它,并且给了我一个错误“无法加载驱动程序:com.mysql.jdbc.Driver”,请参见下一个图片:
If you have ANY idea I will be grateful! 如果您有任何想法,我将不胜感激!
A lot of Java applications do not use the CLASSPATH
environment variable, and it looks like jasperstarter is one of them. 许多Java应用程序不使用
CLASSPATH
环境变量,而jasperstarter就是其中之一。
Looking at http://jasperstarter.cenote.de/usage.html you need to use the command line option --jdbc-dir <directory with driver jar(s)>
: 查看http://jasperstarter.cenote.de/usage.html,您需要使用命令行选项
--jdbc-dir <directory with driver jar(s)>
:
--jdbc-dir <dir>
directory where jdbc driver jars are located.--jdbc-dir <dir>
jdbc驱动程序jar所在的目录。 Defaults to ./jdbc默认为./jdbc
Alternatively, as you indicated in the comments, you can put the driver in the JasperStarter/jdbc
folder, as that is the default location. 另外,如注释中所述,您可以将驱动程序放在
JasperStarter/jdbc
文件夹中,因为这是默认位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.