1 message in com.mysql.lists.java»Ø¸´: Java & SQL connection problem| From | Sent On | Attachments |
|---|---|---|
| ²Ì Óî | 21 May 2000 21:27 |
| Subject: | »Ø¸´: Java & SQL connection problem![]() |
|---|---|
| From: | ²Ì Óî (ca...@glnpu.com) |
| Date: | 05/21/2000 09:27:44 PM |
| List: | com.mysql.lists.java |
-----Original Message----- ·¢¼þÈË: Alfie Lee <alfi...@acay.com.au> ÊÕ¼þÈË: Java & MySQL <ja...@lists.mysql.com> ÈÕÆÚ: 2000Äê5ÔÂ22ÈÕ 11:37 Ö÷Ìâ: Java & SQL connection problem
I am running MySQL on a Linux machine that is Samba'd to a Windows 98 notebook. My problem is that I am getting an error: SQLException: Invalid authorization specification: Access denied for user: 'alfie@' (Using password: NO) SQLState: 28000 VendorError: 1045
The program is fairly basic, it's just a trial connection and uses the basic program structure created on the link from MySQL for Java.
import java.sql.*;
// Notice, do not import org.gjt.mm.mysql.*
// or you will have problems!
public class LoadDriver {
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();
System.out.println("MySQL driver loaded.");
}
catch (Exception E) {
System.err.println("Unable to load driver.");
E.printStackTrace();
}
try {
Connection Conn = DriverManager.getConnection(
"jdbc:mysql://192.168.1.2:3306/odle?user=alfie=password");
// Do something with the Connection
System.out.print("Got here");
Statement Stmt = Conn.createStatement();
ResultSet RS = Stmt.executeQuery("SELECT * FROM people");
while (RS.next()) {
System.out.println(RS.getString(1));
}
// 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());
}
}
}
The database exists and I'm fairly sure the privieges granted are okay as they are wilded to the domain. Any ideas?
Regards Alfie
-- BMR
"jdbc:mysql://192.168.1.2:3306/odle?user=alfie=password"
had been pointed that is not correct; you can use: "jdbc:mysql://192.168.1.2:3306/odle?user=alfie&password=********"
or
String url="jdbc:mysql://192.168.1.2:3306/odle"; ..................... .....................
Connection Conn = DriverManager.getConnection(url,user,password);
try it !
caiyu




