0

Seeing the last part of this article, I'm dying to do the same on my Eclipse.

import jpype
import jaydebeapi

JHOME = jpype.getDefaultJVMPath()
jpype.startJVM(JHOME, '-Djava.class.path=/ojdbc8-full/ojdbc8.jar')
con = jaydebeapi.connect('oracle.jdbc.driver.OracleDriver','jdbc:oracle:thin:XXXXXX/XXXXXX@//99.99.99.99:1521/ABC')
cur = con.cursor()
cur.execute('select dummy from dual')
r = cur.fetchall()
print(r[0][0])
cur.close()
con.close()

And these message have appeard on my screen though, to tell the truth I have no knowledge about JAVA.

raise _RUNTIMEEXCEPTION.PYEXC("Class %s not found" % name)
jpype._jexception.RuntimeExceptionPyRaisable: java.lang.RuntimeException: Class oracle.jdbc.driver.OracleDriver not found

So far, JAVA_HOME environment variable on my computer is the following. java home

Since I don't know which jdbc driver is appropriate for my environment, I haven't actually done anything, he recommended downloading though.

And I don't know even where I should put that driver I would get later. If someone tell me what I should do fast of all, I would be so happy! Thanks.

saya24
  • 57
  • 2
  • 9
  • Are you sure `/ojdbc8-full/ojdbc8.jar` is the correct path for the jar? – Federico klez Culloca Feb 12 '20 at 09:26
  • You should first download `ojdbc8.jar` and pass the full path where your jar will be located at `-Djava.class.path` – Ergi Nushi Feb 12 '20 at 09:27
  • Use `-cp` to set the classpath. – Thorbjørn Ravn Andersen Feb 12 '20 at 09:40
  • Thank you guys for prompt reply. Finally I could get a data from Oracle after I changed like this. jpype.startJVM(JHOME, '-Djava.class.path=C:\Program Files\Java\jdk-13.0.1/ojdbc8.jar') Can I get this portion more cool? Even though I have set JAVA_HOME environment variable, Do I have to write a full path here?? And am bit worried whether this app can work or not on the other computer after I distribute. – saya24 Feb 12 '20 at 10:01
  • Hi Thorbjørn, Could you tell me where I should I put this option "-cp"?? Thank you! – saya24 Feb 12 '20 at 10:05
  • 2
    I'd still recommend using cx_Oracle. Even JDBC requires some kind of "client" software to connect with the DB, which isn't totally different from needing the Oracle C client libraries. – Christopher Jones Feb 12 '20 at 11:34
  • Are you using Python or Jython? In Jython Java driver manager does seem to work. Using Oracle JDBC drivers in Jython is possible but it real PITA. – ibre5041 Feb 12 '20 at 11:50
  • Thank Christopher for your valuable opinion. You mean I don’t have to install oracle client for the computer which I distribute this app to, right? – saya24 Feb 12 '20 at 13:19
  • A JDBC driver does not belong in the installation directory of your Java. You need to put it elsewhere. – Mark Rotteveel Feb 12 '20 at 14:14
  • Hi Mark, I see! Finally I could understand, thank you very much! – saya24 Feb 12 '20 at 23:59
  • Hi guys, I distribute this App adopting cx_Oracle to connect to Oracle DB, But the exe file didn't work on the other computer. That computer hasn't installed any oracle client or instant client. So I'd like to return my policy with JDBC, (Am I wrong? I have no confidence with my dicision)But I' ve faced with another problem. Can't I use prepared statement to add a parameter to the query?? Could someone give me some advise? Thanks! – saya24 Feb 14 '20 at 11:58

0 Answers0