Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

mysql - specifying classpath for standalone jython

I am trying to run a python script via jython on a server that I won't be able to install anything.

I can run

java -jar jython.jar

and that works fine. I am unable to use mm.mysql-2.0.14 driver because it can't find the jar. I set the classpath to include it, as I did on a test system with a standard (that is, non-standalone) jython install. It still says it can't find the jar.

I have tried things like:

export CLASSPATH=/tmp/mm.mysql-2.0.14-bin.jar:/tmp/zxJDBC.jar; java -jar jython.jar

and

java -cp /tmp/mm.mysql-2.0.14-bin.jar  -jar jython.jar

no dice.

still the error: zxJDBC.DatabaseError: driver [org.gjt.mm.mysql.Driver] not found

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In my Windows environment I was able to run:

java -cp c:jarsojdbc6.jar;c:jython2.5.2jython.jar org.python.util.jython schema_ora.py 

where schema_ora.py is a script I want to run which uses Oracle JDBC driver.

I also tried it on Linux with:

[mn@test-db mn]# export CLASSPATH=/usr/local/jars/ojdbc6.jar; /usr/local/jython2.5.2/bin/jython -J-Xmx4048m schema_ora.py jdbc:oracle:thin:@192.168.19.128:1521:testdb usr passwd

So it is possible to run script that way.

As for your problem maybe you do not have rights to see MySQL JDBC driver? I assume you use Linux, so you can check if you can see that file:

file /tmp/mm.mysql-2.0.14-bin.jar

I tried it with Oracle driver on my Linux box:

[mn@test-db mn]# file /usr/local/jars/ojdbc6.jar
/usr/local/jars/ojdbc6.jar: Zip archive data, at least v2.0 to extract

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...