how to over come SQL Exception

Hi friends,

I am working in java with linux platform, I would like to connect the java application with mysql (database).

mycode is

import java.sql.*;

publicclass samplejdbc

{

publicstaticvoid main(String args[])

{

try{

Statement stmt;

ResultSet rs;

//Register the JDBC driver for MySQL.

Class.forName("com.mysql.jdbc.Driver").newInstance();

//Define URL of database server for database named mcadb

String url="jdbc:mysql:l10n";

//Get a connection to the database for a user named auser with the password

Connection con =DriverManager.getConnection(url,"mecse102","sample");

//Display URL and connection information

System.out.println("URL: " + url);

System.out.println("Connection: " + con);

//Get a Statement object

stmt = con.createStatement();

rs=stmt.executeQuery("select * from temp");

while(rs.next())

{

System.out.println(rs.getString(1));

System.out.println(rs.getString(2));

}

rs.close();

}

catch(Exception e)

{

System.out.println("Error "+e);

}

}//end main

}//end class samplejdbc

The output isError java .sql.SQLException:No suitable driver.

How can I over come this.

Thanks in advance

ARP with reg.

[2364 byte] By [abp_JavaPrg@mdua] at [2007-11-26 19:48:08]
# 1
the Mysql driver jar is not on your classpath
georgemca at 2007-7-9 22:35:32 > top of Java-index,Java Essentials,New To Java...
# 2
Try downloading the driver from the following location http://dev.mysql.com/downloads/connector/j/5.0.htmland then add this driver in JAVA CLASS_PATH
amit.naranga at 2007-7-9 22:35:32 > top of Java-index,Java Essentials,New To Java...
# 3
we have downloaded that j connector and add the /mysql-connector-java-5.0.4-bin.jar in my classpath.but still we have the same error.
abp_JavaPrg@mdua at 2007-7-9 22:35:32 > top of Java-index,Java Essentials,New To Java...
# 4

while I modified the code like this

String url = "jdbc:mysql://127.0.0.1:3306/l10n

instead of String url="jdbc:mysql:l10n"

I got error like this

URL is :jdbc:mysql://127.0.0.1:3306/l10n?user=mecse102&password=sample

Error java.sql.SQLException: null, message from server: "#HY000Host '127.0.0.1' is not allowed to connect to this MySQL server"

Kindly help me to over come this

ARP with reg.

abp_JavaPrg@mdua at 2007-7-9 22:35:32 > top of Java-index,Java Essentials,New To Java...
# 5

That is a configuration problem in your MySQL DB. Read the MySQL manual, concentrating on the "GRANT" statement and user privileges. You not only have to create a user, you have to tell MySQL where that user is allowed to connect from. Otherwise, it is only allowed to connect from localhost using the sock file and not over tcp.

masijade.a at 2007-7-9 22:35:32 > top of Java-index,Java Essentials,New To Java...