-2

Below is the code I am trying to use to connect to a database and view reports in the JasperViewer.

 private void jButton1ActionPerformed(ActionEvent evt) {
     try {
         String dbURL = "jdbc:oracle:thin:@localhost:1521:xe";
         String username = "user";
         String password = "pwd";
         Connection con = DriverManager.getConnection(dbURL, username, password);
         String reportPath = "C:\\path\\extention.jrxml";
         JasperReport jr = JasperCompileManager.compileReport(reportPath);
         JasperPrint jp = JasperFillManager.fillReport(jr, null, con);
         JasperViewer.viewReport(jp);
         con.close();
     } catch (Exception ex) {
         System.out.println(ex.getMessage());
     }
 }

I got the following error:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
Alex K
  • 22,315
  • 19
  • 108
  • 236
Mahmoud
  • 1
  • 2

1 Answers1

1

I don't know much about Jasper, but I assume it has a dependency on Apache Commons Log Framework, so you probably need to add Apache Commons Logging to your classpath.

See: https://commons.apache.org/proper/commons-logging/guide.html

thetechnician94
  • 545
  • 2
  • 21