[pydev - Users] finding a java class using Jython

View: New views
5 Messages — Rating Filter:   Alert me  

[pydev - Users] finding a java class using Jython

by SourceForge.net :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=7575202
By: rbleasdale

I am a beginner and have had some success with Python and pydev and wanted to
use Jython and DB2 JDBC in pydev.

I found some sample code which works fine at the command prompt but not within
pydev

Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance()
con = DriverManager.getConnection( 'jdbc:db2:sample','db2admin','password')

When I run it claims it cannot find the class

java.lang.ClassNotFoundException: java.lang.ClassNotFoundException:
COM.ibm.db2.jdbc.app.DB2Driver

I have added the DB2 jar files and folder  to PYTHONPATH libraries and added
them to the module folder. All to no avail.



Can anybody tell me how I can persuade pydev to find the jars

Thanks


______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=293649

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Pydev-users mailing list
Pydev-users@...
https://lists.sourceforge.net/lists/listinfo/pydev-users

[pydev - Users] RE: finding a java class using Jython

by SourceForge.net :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=7575384
By: fabioz

I checked the Class.forName and it works for me when adding a jar to the
pythonpath... are you sure the path is correct?

Another thing, I find it really strange that  the 'COM' is added there in uppercase
and not in lowercase (are you sure that's correct?)

Also, you don't need the newinstance() there (just doing the forName should
be enough).

Cheers,

Fabio

______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=293649

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Pydev-users mailing list
Pydev-users@...
https://lists.sourceforge.net/lists/listinfo/pydev-users

[pydev - Users] RE: finding a java class using Jython

by SourceForge.net :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=7579408
By: rbleasdale

Despite its unusual look COM is correct.

If I run
    jython example.py
at the command prompt then the class is found.

I have re-added the db2 jars to pythonpath library and when I run
*sys-package-mgr*: processing new jar shows in the console

I wondered if there is a Java path I need to add the jars to?

Cheers,

Roy


______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=293649

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Pydev-users mailing list
Pydev-users@...
https://lists.sourceforge.net/lists/listinfo/pydev-users

[pydev - Users] RE: finding a java class using Jython

by SourceForge.net :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=7581302
By: fabioz

Can you add:

import sys
for p in sys.path: print p

>From both the command prompt and from eclipse and paste the results for each
one?

Cheers,

Fabio

______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=293649

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Pydev-users mailing list
Pydev-users@...
https://lists.sourceforge.net/lists/listinfo/pydev-users

[pydev - Users] RE: finding a java class using Jython

by SourceForge.net :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=7581510
By: rbleasdale

At the Command Prompt:

C:\eclipseWorkspacesPy\TADzJy\src\tools>jython exam2.py
C:\eclipseWorkspacesPy\TADzJy\src\tools
C:\jython2.5.0\Lib
__classpath__
__pyclasspath__/
C:\jython2.5.0\Lib\site-packages
my program
passed connection

>From Eclipse:

C:\eclipseWorkspacesPy\TADzJy\src\tools
C:\eclipseWorkspacesPy\TADzJy\src
C:\jython2.5.0\Lib
C:\jython2.5.0\Lib\site-packages
C:\Program Files\IBM\Java50\jre\lib\vm.jar
C:\Program Files\IBM\Java50\jre\lib\core.jar
C:\Program Files\IBM\Java50\jre\lib\charsets.jar
C:\Program Files\IBM\Java50\jre\lib\graphics.jar
C:\Program Files\IBM\Java50\jre\lib\security.jar
C:\Program Files\IBM\Java50\jre\lib\ibmpkcs.jar
C:\Program Files\IBM\Java50\jre\lib\ibmorb.jar
C:\Program Files\IBM\Java50\jre\lib\ibmcfw.jar
C:\Program Files\IBM\Java50\jre\lib\ibmorbapi.jar
C:\Program Files\IBM\Java50\jre\lib\ibmjcefw.jar
C:\Program Files\IBM\Java50\jre\lib\ibmjgssprovider.jar
C:\Program Files\IBM\Java50\jre\lib\ibmjsseprovider2.jar
C:\Program Files\IBM\Java50\jre\lib\ibmjaaslm.jar
C:\Program Files\IBM\Java50\jre\lib\ibmjaasactivelm.jar
C:\Program Files\IBM\Java50\jre\lib\ibmcertpathprovider.jar
C:\Program Files\IBM\Java50\jre\lib\server.jar
C:\Program Files\IBM\Java50\jre\lib\xml.jar
C:\Program Files\IBM\Java50\jre\lib\ext\CmpCrmf.jar
C:\Program Files\IBM\Java50\jre\lib\ext\dtfj-interface.jar
C:\Program Files\IBM\Java50\jre\lib\ext\dtfj.jar
C:\Program Files\IBM\Java50\jre\lib\ext\gskikm.jar
C:\Program Files\IBM\Java50\jre\lib\ext\ibmcmsprovider.jar
C:\Program Files\IBM\Java50\jre\lib\ext\ibmjcefips.jar
C:\Program Files\IBM\Java50\jre\lib\ext\ibmjceprovider.jar
C:\Program Files\IBM\Java50\jre\lib\ext\ibmkeycert.jar
C:\Program Files\IBM\Java50\jre\lib\ext\IBMKeyManagementServer.jar
C:\Program Files\IBM\Java50\jre\lib\ext\ibmpkcs11.jar
C:\Program Files\IBM\Java50\jre\lib\ext\ibmpkcs11impl.jar
C:\Program Files\IBM\Java50\jre\lib\ext\ibmsaslprovider.jar
C:\Program Files\IBM\Java50\jre\lib\ext\indicim.jar
C:\Program Files\IBM\Java50\jre\lib\ext\jaccess.jar
C:\Program Files\IBM\Java50\jre\lib\ext\JawBridge.jar
C:\Program Files\IBM\Java50\jre\lib\ext\jdmpview.jar
C:\jython2.5.0\db2jcc.jar
my program
Traceback (most recent call last):
  File "C:\eclipseWorkspacesPy\TADzJy\src\tools\exam2.py", line 24, in <module>
    Start()
  File "C:\eclipseWorkspacesPy\TADzJy\src\tools\exam2.py", line 15, in Start
    Class.forName("COM.ibm.db2.jdbc.app.DB2Driver")
        at java.lang.Class.forName(Class.java:130)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64
)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:43)

        at java.lang.reflect.Method.invoke(Method.java:615)


java.lang.ClassNotFoundException: java.lang.ClassNotFoundException:
COM.ibm.db2.jdbc.app.DB2Driver

Hope this helps.

Cheers,

Roy

______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=293649

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Pydev-users mailing list
Pydev-users@...
https://lists.sourceforge.net/lists/listinfo/pydev-users