User Authentication failed.请教原因

Web、Mail、Ftp、DNS、Proxy、VPN、Samba、LDAP 等基础网络服务
回复
77519697
帖子: 26
注册时间: 2006-07-20 15:44

User Authentication failed.请教原因

#1

帖子 77519697 » 2006-10-21 12:00

我执行完 java -jar Testdb.jar如下
我最想知道的是
com.mckoi.database.jdbc.SQLLoginException: User Authentication failed.
at com.mckoi.database.jdbc.RemoteDatabaseInterface.login(RemoteDatabaseInterface.java:170)
at com.mckoi.database.jdbc.MConnection.login(MConnection.java:295)
at com.mckoi.database.jdbc.MConnection.login(MConnection.java:341)
at com.mckoi.database.jdbc.MDriver.connect(MDriver.java:600)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at TestDB.getConnection(Main.java:47)
at TestDB.runTest(Main.java:21)
at TestDB.main(Main.java:7)
这是什么原因引起的
其中源程序 如下
import java.sql.*;

import java.io.*;

import java.util.*;

class TestDB

{public static void main (String args[])

{try

{runTest();

}

catch (SQLException ex)

{while (ex !=null)

{ex.printStackTrace();

ex=ex.getNextException();

}

}

catch (IOException ex)

{ex.printStackTrace();

}

}

public static void runTest()

throws SQLException,IOException

{Connection conn=getConnection();

try

{Statement stat=conn.createStatement();

stat.execute("CREATE TABLE Greetings (Message CHAR(20))");

stat.execute("INSERT INTO Greetings VALUES ('hello,world:')");

ResultSet result=stat.executeQuery("SELECT * FROM Greetings");

result.next();

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

stat.execute("DROP TABLE Greetings");

}

finally

{conn.close();

}

}

public static Connection getConnection()

throws SQLException,IOException

{Properties props = new Properties();

FileInputStream in = new FileInputStream("database.properties");

props.load(in);

in.close();

String drivers=props.getProperty("jdbc.drivers");

if (drivers !=null)

System.setProperty("jdbc.drivers",drivers);

String url=props.getProperty("jdbc.url");

String username=props.getProperty("jdbc.username");

String password=props.getProperty("jdbc.password");

return DriverManager.getConnection(url,username,password);

}

}
回复