public class ReportView extends JFrame {
Connection con=null;
void showReport() throws SQLException, ClassNotFoundException, JRException {
con=DriverManager.getConnection("jdbc:postgresql://localhost:5432/Test");
JasperReport report=JasperCompileManager.compileReport("Testing.jrxml");
JasperPrint print=JasperFillManager.fillReport(report,null,con);
JRViewer viewer=new JRViewer(print);
viewer.setOpaque(true);
viewer.setVisible(true);
this.add(viewer);
this.setSize(300, 200);
this.setVisible(true);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
这是错误:
Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost:5432/Test
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
有什么问题吗?
- 您需要在某处加载驱动程序。
Class.forName("org.postgresql.Driver");
- 您需要在程序的类路径中放置 postgresql 驱动程序 .jar 文件。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)