java错误(找不到合适的驱动程序) [英] java error (No suitable driver found)
本文介绍了java错误(找不到合适的驱动程序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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文件您的计划。
这篇关于java错误(找不到合适的驱动程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文