Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection to Oracle databases #120

Open
JBAltidor opened this issue Dec 17, 2021 · 8 comments
Open

Connection to Oracle databases #120

JBAltidor opened this issue Dec 17, 2021 · 8 comments

Comments

@JBAltidor
Copy link

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
Copy link
Collaborator

Could you send us the full log?

@JBAltidor
Copy link
Author

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
Copy link
Collaborator

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
Copy link
Author

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
Copy link
Collaborator

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.

@Nenadst023
Copy link

Nenadst023 commented Mar 4, 2023

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
Copy link
Author

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
Copy link

gph commented Apr 17, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants