acesseonline / pyreportjasper

Python Reporting with JasperReports
https://pyreportjasper.readthedocs.io/en/latest/
GNU General Public License v3.0
125 stars 69 forks source link

Connection to Oracle databases #120

Open JBAltidor opened 2 years ago

JBAltidor commented 2 years ago

Connections to oracle databases keeps throwing errors : • NameError: Error fill report: Erro fill internal: java.lang.NullPointerException
• NameError: Error fill report: Java package 'net' is not valid The second I can't get around.

jadsonbr commented 2 years ago

Could you send us the full log?

JBAltidor commented 2 years ago

Traceback (most recent call last): File "c:*\cons_oracle.py", line 39, in oracle_database() File "c:*\cons_oracle.py", line 32, in oracle_database pyreportjasper.process_report() File "C:***\pyreportjasper.py", line 182, in process_report raise error NameError: Error fill report: Java package 'net' is not valid


Connection dictionnary conn = { 'driver': 'oracle', 'username': 'user', 'password': , 'host': , 'schema': **, 'port': ', 'jdbc_driver' : "oracle.jdbc.driver.OracleDriver", 'jdbc_dir': 'ojdbc8.jar' }

jadsonbr commented 2 years ago

try like this

Uninstall pyreportjasper

and install with

pip3 install git+https://github.com/acesseonline/pyreportjasper.git

and

  conn = {
    'driver': 'oracle',
    'username': '****',
    'password': '****',
    'db_sid': '****',
    'host': ****,
    'port': ****',
    'jdbc_driver' : "oracle.jdbc.driver.OracleDriver",
    'jdbc_dir': "C:\drivers\", # Inform the folder containing the jar file
  }
   pyreportjasper = PyReportJasper()
   pyreportjasper.config(
      input_file,
      output_file,
      output_formats=["pdf"],
      db_connection=conn,
      resource="C:\drivers"
   )
   pyreportjasper.process_report()
JBAltidor commented 2 years ago

Tried it, got that error : NameError: Error fill report: It was not possible to add the path C:/Users/**/Drivers to the Class Path: ERROR: java.io.IOException: Error, could not add URL to system classloader!

jadsonbr commented 2 years ago

To help, provide more details. If possible provide the code snippet you are running and attach the jdbc .jar file

Describe A clear and concise description.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Jaspersoft Studio (please complete the following information):

Additional context Add any other context about the problem here.

Nenadst023 commented 1 year ago

Hi,

I have same problem. My code..

import os
from pyreportjasper import PyReportJasper

os.environ["JAVA_HOME"] ="jvm/jdk-19.0.2/"

def advanced_example_using_database():
   REPORTS_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'jrxml')
   input_file = os.path.join(REPORTS_DIR, 'stampaCenaA4.jrxml')
   output_file = os.path.join(REPORTS_DIR, 'stampaCenaA4')

   conn = {
     'driver': 'oracle',
     'username': '***',
     'password': '***',
     'host': '***',
     'port': '1521',
     'db_sid': '***',
     'jdbc_dir': 'x:\\nenad_ws\\-- PY RAZVOJ\\StampaCena\\oracle\\',
     'jdbc_driver': 'oracle.jdbc.driver.OracleDriver'
   }

   pyreportjasper = PyReportJasper()
   pyreportjasper.config(
     input_file,
     output_file,
     db_connection=conn,
     output_formats=["pdf"],
     parameters={'poj': '114', 'pbarkod':'8600043003444,8605006902987,7622210702593,9012200872739,3080216031811'},
     resource="x:\\nenad_ws\\-- PY RAZVOJ\\StampaCena\\oracle",
     locale='en_US'
   )
   pyreportjasper.process_report()

advanced_example_using_database()

Output: NameError: Error fill report: It was not possible to add the path x:\nenad_ws-- PY RAZVOJ\StampaCena\oracle\ to the Class Path: ERROR: java.io.IOException: Error, could not add URL to system classloader!

Project path.. image

Python ver: 3.10.7 Lib installed with pip3 install git+https://github.com/acesseonline/pyreportjasper.git - Version: 2.1.2 Java: open jdk-19.0.2 Jvm: Oracle OS: windows 11

Jaspersoft Studio: 6.20.0

JBAltidor commented 1 year ago

I still don't know how to make this thing work. But, I had a deadline so I worked aroud it by calling a bit of python code inside Java (as it woked perfectly with python). Don't know if that helps.

gph commented 1 year ago

I still don't know how to make this thing work. But, I had a deadline so I worked aroud it by calling a bit of python code inside Java (as it woked perfectly with python). Don't know if that helps.

Would you mind sharing your implementation?

Best Regards! Henry Gamba