처음으로 jython을 시도해보십시오. 왜냐하면 뭔가 완벽하게 작동하기에 적합하기 때문입니다. 자이 썬이 mysql jdbc 연결을 mysql jdbc 드라이버를 사용하여 만들 수 있다고 가정합니다. 검색 및 독서 후, 그러나 나는 문제가 있고 자이 썬 구체적이고 아마 간단합니다. 는 그래서는 자이 썬 수행Jython & MySQL - 현재 연결 관행은 무엇입니까?
Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54)
[Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_17
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.path
['', '/JYTHONPATH/mysql-connector-java-5.1.10-bin.jar', '/WorkArea/Apps/jython/jython2.5.1/Lib', '__classpath__', '__pyclasspath__/', '/WorkArea/Apps/jython/jython2.5.1/Lib/site-packages']
>>>
코드 내가
from java.lang import *
from java.sql import *
driverName="com.mysql.jdbc.Driver"
Class.forName(driverName)
url = "jdbc:mysql://localhost/test?user=jgreenaw&password="
con = DriverManager.getConnection(url)
stmt = con.createStatement()
출력
riux:Desktop$ jython pymysql.py
Traceback (most recent call last):
File "pymysql.py", line 7, in <module>
Class.forName(driverName)
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:315)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:330)
at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
java.lang.ClassNotFoundException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
어떤 조언을하고 있는데?
감사합니다.
"/JYTHONPATH/mysql-connector-java-5.1.10-bin.jar"가 존재합니까? – AndiDog
예 : riuxjg : JYTHONPATH $ ls mysql-connector-java-5.1.10-bin.jar – Sector7B
올바른 경로가 이론상 올바른 것으로 가정합니다. – Sector7B