« Return to Thread: Jython Class.forName()

Re: Jython Class.forName()

by Frank Wierzbicki :: Rate this Message:

Reply to Author | View in Thread

On Tue, Jul 7, 2009 at 10:39 AM, Carl<s7plc@...> wrote:

> I am trying to use the jtds driver to connect to a MSSQL database, and can’t
> get past the Class.forName line in the code. I have done exhausting google
> searches and found others with the same problem, but no definitive solution
> or workaround. I’m guessing there must be something wrong with my Jython
> setup or installation.
>
>
>
> I am testing with NetBeans 6.7, and have tried this with Jython versions
> 2.2, 2.5b0+, and 2.5rc3. Within NetBeans, under services, I set up the jtds
> driver, and was able to define a URL and connect to my database, so I assume
> the rest of my code will work if I get past the Class.forName problem.
>
>
>
> The code is pretty basic:
>
>
>
> from java.sql import DriverManager
>
> from java.lang import Class
>
>
>
> Class.forName("net.sourceforge.jtds.jdbc.Driver")
>
>
>
> Error: “java.lang.ClassNotFoundException: java.lang.ClassNotFoundException:
> net.sourceforge.jtds.jdbc.Driver”
>
>
>
> I found one note that mentioned adding “–verify” to the command arguments,
> but other notes saying that it wasn’t necessary with version 2.5.
--verify is gone in 2.5.0.  The one thing to make sure of is that you
are not calling jython with the --boot option (the behavior of
--verify is now the default, --boot puts jython on the boot classpath,
which would cause this problem).

This almost certainly means that you don't have
"net.sourceforge.jtds.jdbc.Driver" on your classpath.  You could test
this another way by trying the following jython code:

from net.sourceforge.jtds.jdbc import Driver

Have you tried the equivalent Java code in your environment?  That's
another good troubleshooting step.

-Frank

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/blackberry
_______________________________________________
Jython-users mailing list
Jython-users@...
https://lists.sourceforge.net/lists/listinfo/jython-users

 « Return to Thread: Jython Class.forName()