Hi friends,
i installed Mysql 3.23.36 in my Red Hat 7.1 system.
i am using "mm.mysql-2.0.6.1.jar" jdbc driver for connceting to my mysql database.
my program is:
import java.sql.*;
public class TestMysql
{
public static void main(String[] Args)
{
try {
// The newInstance() call is a work around for some
// broken Java implementations
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
}
catch (Exception E) {
System.err.println("Unable to load driver.");
E.printStackTrace();
}
System.out.println("Registration is over \n\n");
try {
/* Connection Management */
//Here test is the database name
//vanuganti--UID
//venu--PWD
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","shanmukh");
System.out.println("\nAfter get connection\n\n");
conn.setAutoCommit(true); /* Create stmt and process some basic SQL statements */
Statement stmt = conn.createStatement();
stmt.execute("drop table test_mysql");
stmt.execute("create table test_mysql(col1 int, col2 varchar(25))");
stmt.execute("insert into test_mysql values(100,'mysql')");
stmt.execute("insert into test_mysql values(200,'myjdbc')"); /* Result set */
ResultSet rs = stmt.executeQuery("SELECT * FROM test_mysql");
while (rs.next())
{
System.out.println("COL1:"+rs.getInt(1));
System.out.println("COL2:"+rs.getString(2));
} // Clean up after ourselves
rs.close();
stmt.close();
conn.close();
}
catch (SQLException E) {
System.out.println("SQLException: " + E.getMessage());
System.out.println("SQLState: " + E.getSQLState());
System.out.println("VendorError: " + E.getErrorCode());
}
}
}
i successfully compiled above prorgram.
i had set proper classpath for jdbc drivers and my username , password and database
name,port no also correct.
i am able to connect to mysql server using that username,password at COMMAND line. but
while connecting to database from above java program
mysql server and program are running on the same system.
i am getting this exception
SQLException: Invalid authorization specification: Access denied for user:
'[EMAIL PROTECTED]' (Using password: YES)
SQLState: 28000
VendorError: 1045
please any body can help me..
Thanks in advance....
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php