| Author |
MYSQL Connection error Plz help
|
prashant parab
Greenhorn
Joined: Jan 10, 2002
Posts: 17
|
|
Hi All, I am getting following error while connecting to MYSQL server Following is my code import java.sql.*; public class test{ public test(){ try{ Class.forName("org.gjt.mm.mysql.Driver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/ejb?user=root&password=ypbind$12"); Statement stat=conn.createStatement(); ResultSet rs=stat.executeQuery("select * from prashant"); while(rs.next()){ System.out.println("Name "+rs.getString("name")); } }catch(Exception ee){ ee.printStackTrace(); } } public static void main(String a[]){ new test(); } } I am getting following exception. I am able to connect to mysql server using mysql command on command prompt using the same user name and password java.sql.SQLException: General error: Access denied for user: '@localhost' to da tabase 'ejb?user=root&password=ypbind$12' at org.gjt.mm.mysql.MysqlIO.sendCommand(MysqlIO.java) at org.gjt.mm.mysql.Connection.<init>(Connection.java) at org.gjt.mm.mysql.Driver.connect(Driver.java) at java.sql.DriverManager.getConnection(DriverManager.java:512) at java.sql.DriverManager.getConnection(DriverManager.java:193) at test.<init>(test.java:8) at test.main(test.java:20) Please help
|
 |
Hartmut Ludwig
Ranch Hand
Joined: Aug 31, 2002
Posts: 51
|
|
Try the following: Put Username and Password and the URL itself in separate Strings. Now you can use the following: I'm quite shure that this will work.
|
 |
prashant parab
Greenhorn
Joined: Jan 10, 2002
Posts: 17
|
|
Thanx for your immediate response. I tried that and atleast now i am not getting that error. Now it is throwing the following exception. Can you kindly tell me reason behind this. java.sql.SQLException: General Error: null at org.gjt.mm.mysql.Connection.<init>(Connection.java) at org.gjt.mm.mysql.Driver.connect(Driver.java) at java.sql.DriverManager.getConnection(DriverManager.java:512) at java.sql.DriverManager.getConnection(DriverManager.java:171) at test.<init>(test.java:11) at test.main(test.java:23)
|
 |
 |
|
|
subject: MYSQL Connection error Plz help
|
|
|