pyreportjasper icon indicating copy to clipboard operation
pyreportjasper copied to clipboard

Connection to Oracle databases

Open JBAltidor opened this issue 3 years ago • 8 comments

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.

JBAltidor avatar Dec 17 '21 15:12 JBAltidor

Could you send us the full log?

jadsonbr avatar Dec 17 '21 17:12 jadsonbr

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' }

JBAltidor avatar Dec 17 '21 19:12 JBAltidor

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()

jadsonbr avatar Dec 17 '21 19:12 jadsonbr

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!

JBAltidor avatar Dec 20 '21 13:12 JBAltidor

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):

  • OS: [e.g. Linux]
  • Python version [e.g. 3.8]
  • Library version [e.g. 2.1.0]
  • Java version [e.g. 15]
  • JVM [e.g. Oracle]

Jaspersoft Studio (please complete the following information):

  • Version [e.g. 6.16.0]

Additional context Add any other context about the problem here.

jadsonbr avatar Dec 27 '21 12:12 jadsonbr

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

Nenadst023 avatar Mar 04 '23 23:03 Nenadst023

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.

JBAltidor avatar Mar 05 '23 15:03 JBAltidor

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

gph avatar Apr 17 '23 18:04 gph