Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Database Connection using Class.forName

1 view
Skip to first unread message

tamasu

unread,
Nov 2, 2009, 3:21:25 PM11/2/09
to
Hi,

First of all I am new to java. I would like to connect to a database
using the Class.forName method but I am having some difficulties


If the said method is set in the main form everything works as it
should but if I can't figure out how I can instansiated through a
class. I am receiving java.lang.ClassNotFoundException


I can confirm that the driver is correct as I managed to connect
through netbeans using the same driver details


The driver I am using is - com.mysql.jdbc.Driver and the
ConnectionUrl
is jdbc:mysql://localhost/<DatabaseName>


Any ideas?


Kind Regards
Jansen


John B. Matthews

unread,
Nov 2, 2009, 4:46:49 PM11/2/09
to
In article
<aed26126-22a8-4d9d...@f16g2000yqm.googlegroups.com>,
tamasu <tamas...@gmail.com> wrote:

You need to be sure that the JAR containing the driver is in the class
path when you compile or run:

http://java.sun.com/javase/6/docs/technotes/tools/solaris/classpath.html
http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html

As the MySQL driver JAR is known to NetBeans (Tools > Libraries), a copy
should appear in the dist/lib directory when you build your project.

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>

0 new messages