i'm connecting Java with Mysql on windows and facing problem in establishing connection.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Saqib_Rauf
Posted On:   Monday, December 23, 2002 11:10 PM

i have installed MYSQL 3.23.54 for window XP and a JDBC connector mysql-connector-java-2.0.14. i have set the classpath for JDBC driver as C:> set CLASSPATH=path omm.mysql.jdbc-[version];%CLASSPATH% and my code for testing the connection is import java.sql.*; public class Connect { public static void main (String[] args) { Connection conn = null; try { String userName = "saqib"; String password = "123"; String url = "jdbc:mysql://localhost/test"; Class.forName ("org.gjt.mm.mysql.Driver").newInstance (); conn = DriverManager.getConnection (url, userName, password); System.out.println (   More>>

i have installed MYSQL 3.23.54 for window XP and a JDBC connector mysql-connector-java-2.0.14.
i have set the classpath for JDBC driver as
C:> set CLASSPATH=path omm.mysql.jdbc-[version];%CLASSPATH%

and my code for testing the connection is
import java.sql.*;
public class Connect
{
public static void main (String[] args)
{
Connection conn = null;
try
{
String userName = "saqib";
String password = "123";
String url = "jdbc:mysql://localhost/test";
Class.forName ("org.gjt.mm.mysql.Driver").newInstance ();
conn = DriverManager.getConnection (url, userName, password);
System.out.println ("Database connection established");
}
catch (Exception e)
{
System.err.println ("Cannot connect to database server");
}

finally
{
try
{
if (conn != null)
{
conn.close ();
System.out.println ("Database connection terminated");
}
}
catch (Exception e) { /* ignore close errors */ }
}
}
}
. the problem i'm facing is that when i compile and run the program the following message is generated.

Exceprion in thread "main" java.lang.NoClassDefFoundError: Coonect

please help me out to establist the connection. is the classpath which i have set is correct. i have placed the unziped driever in the folder c.

thanks

Saqib

   <<Less

Re: i'm connecting Java with Mysql on windows and facing problem in establishing connection.

Posted By:   vinay_salehithal  
Posted On:   Tuesday, December 24, 2002 11:40 AM

Seems like yr main class (Connect) itself is not being found.
try

set CLASSPATH=.;path omm.mysql.jdbc-[version];%CLASSPATH%

About | Sitemap | Contact