Please note that Sahi's development and support teams do not actively monitor this. This is more a community forum. If you are a Sahi Pro user looking for commercial support, please email support @ sahipro.com with your query.

MySQL ClassNotFoundException

poolapoola Members
edited 10:40AM in Sahi - Open Source
HI,

I am new to sahi. I am trying to connect to myql database by following the procedure to set the class path through forums. But I am unable to connect to mysql database. Im gettin the following exception on the console. I downloaded mysql-connector-java-5.0.4-bin and pasted in D:\sahi\extlib\db directory. Please help.

SAHI_HOME: ..
SAHI_USERDATA_DIR: ..\userdata
SAHI_EXT_CLASS_PATH: ..\ext\lib\db\mysql-connector-java-5.0.4-bin.jar
Sahi properties file = D:\sahi\config\sahi.properties
Sahi user properties file = D:\sahi\userdata\config\userdata.properties
>>>> Sahi started. Listening on port: 9999
>>>> Configure your browser to use this server and port as its proxy
>>>> Browse any page and CTRL-ALT-DblClick on the page to bring up the Sahi Cont
roller
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at net.sf.sahi.util.ClassLoadHelper.getClass(ClassLoadHelper.java:24)
at net.sf.sahi.plugin.DBClient.getResult(DBClient.java:95)
at net.sf.sahi.plugin.DBClient.select(DBClient.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:161)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:24
7)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)

at org.mozilla.javascript.gen.c1._c56(<cmd>:461)
at org.mozilla.javascript.gen.c1.call(<cmd>)
at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)

at org.mozilla.javascript.gen.c2._c0(<cmd>:3)
at org.mozilla.javascript.gen.c2.call(<cmd>)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:3
98)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:306
5)
at org.mozilla.javascript.gen.c2.call(<cmd>)
at org.mozilla.javascript.gen.c2.exec(<cmd>)
at org.mozilla.javascript.Context.evaluateString(Context.java:1104)
at net.sf.sahi.rhino.RhinoScriptRunner.run(RhinoScriptRunner.java:91)
at java.lang.Thread.run(Unknown Source)



Thanks in advance
Regards,
Poola.

Comments

  • narayannarayan Administrators
    Can you paste the absolute path of mysql-connector-java-5.0.4-bin.jar? Did you copy the msql jar to ext\lib\db\ folder?

    I guess the jar is not available at ..\ext\lib\db\mysql-connector-java-5.0.4-bin.jar
  • poolapoola Members
    Hi narayan,

    I gave the absolute path wrongly in sahi.bat. Now i am able to connect to mysql DB.

    Thanks,
    Poola
  • monicasmonicas Members
    I'm still getting the error. can anyone please help me.. it's bit urgent..
    I have copied the mysql jar at C:\Users\monicas\sahi_pro\extlib\db.

    start_sahi.bat is as follows:

    @ECHO OFF
    SET SAHI_HOME=..\..
    SET SAHI_USERDATA_DIR=..\userdata
    set SAHI_CLASS_PATH=%SAHI_HOME%\lib\sahi.jar;%SAHI_HOME%\extlib\rhino\js.jar;%SAHI_HOME%\extlib\apc\commons-codec-1.3.jar
    SET SAHI_EXT_CLASS_PATH=%SAHI_HOME%\extlib\db\mysql-connector-java-5.1.45-bin.jar
    SET MOZ_NO_REMOTE=1
    CALL setjava.bat
    CALL %SAHI_HOME%\bin\sahi.bat

    and sahi.sh is as follows:

    if [ ! $SAHI_HOME ]
    then
    export SAHI_HOME=..
    fi
    if [ ! $SAHI_USERDATA_DIR ]
    then
    export SAHI_USERDATA_DIR_TMP=$SAHI_HOME/userdata
    else
    export SAHI_USERDATA_DIR_TMP=$SAHI_USERDATA_DIR
    fi
    echo
    echo java -version
    echo SAHI_HOME: $SAHI_HOME
    echo SAHI_USERDATA_DIR: $SAHI_USERDATA_DIR_TMP
    echo SAHI_EXT_CLASS_PATH: %SAHI_HOME%\extlib\db\mysql-connector-java-5.1.45-bin.jar
    echo

    export POI_JARS=$SAHI_HOME/extlib/poi/excelpoi.jar:$SAHI_HOME/extlib/poi/poi.jar:$SAHI_HOME/extlib/poi/dom4j-1.6.1.jar:$SAHI_HOME/extlib/poi/poi-ooxml.jar:$SAHI_HOME/extlib/poi/poi-ooxml-schemas.jar:$SAHI_HOME/extlib/poi/xmlbeans.jar
    export JAVAX_MAIL_JARS=$SAHI_HOME/extlib/mail/mail.jar:$SAHI_HOME/extlib/mail/activation.jar
    export C3P0_JARS=$SAHI_HOME/extlib/c3p0/c3p0-0.9.5-pre5.jar:$SAHI_HOME/extlib/c3p0/mchange-commons-java-0.2.6.2.jar
    export APPLET_JARS=$SAHI_HOME/extlib/javassist/javassist.jar:$SAHI_HOME/extlib/sahi/sahiapplet.jar
    export ANDROID_JAR=%SAHI_HOME%/lib/sahi_android_desktop_dependency.jar
    SAHI_CLASS_PATH=$SAHI_HOME/lib/sahi.jar:$SAHI_HOME/extlib/rhino/js.jar:$SAHI_HOME/extlib/apc/commons-codec-1.3.jar:$SAHI_HOME/extlib/db/h2.jar:$SAHI_HOME/extlib/license/truelicense.jar:$SAHI_HOME/extlib/license/truexml.jar:$POI_JARS:$JAVAX_MAIL_JARS:$C3P0_JARS:$APPLET_JARS:$ANDROID_JAR

    java -Djava.util.logging.config.file=$SAHI_USERDATA_DIR_TMP/config/log.properties -classpath %SAHI_HOME%\extlib\db\mysql-connector-java-5.1.45-bin.jar:$SAHI_CLASS_PATH net.sf.sahi.Proxy "$SAHI_HOME" "$SAHI_USERDATA_DIR_TMP"
Sign In or Register to comment.