问题1: No suitable driver found for jdbc:mysql
背景:在使用iReport设计报表模版,使用到subreport的时候,一般都是设计好subreport之后,将subreport嵌入masterreport使用,然而在嵌入subreport的时候,需要定义一个连接,比如: java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/dbname","username","passwd") ,但是最后生成报表preview的时候会报错No suitable driver foundfor jdbc:mysql。 问题解决:
这最主要还是个driver的问题,关于这个,则必须要将mysql-connector.jar放到正确的位置:
可以参考:http://community.jaspersoft.com/questions/534375/multi-database-issue-lets-see-if-someone-can-help
其中主要的内容为:
OK, here is the solution for Ubuntu 10.10 with netbeans 6.8 and 6.9.1, plus iReport, please post here where you find other solutions as well, as this applies on Windows as well.
Forget the classes folder, the driver has to be located in this folder to have it working correctly:
/usr/lib/jvm/java-6-sun-1.6xxxx/jre/lib/ext (xxx for whatever revision you have).
我的jar包为: mysql-connector-java-5.1.7-bin.jar。关于这个目录地址,肯定不完全一样,视具体情况而需灵活运用。