java问题 (急用)User Authentication failed.

C、C++和Java语言
回复
77519697
帖子: 26
注册时间: 2006-07-20 15:44
送出感谢: 0
接收感谢: 0

java问题 (急用)User Authentication failed.

#1

帖子 77519697 » 2006-10-16 13:56

At first I made sure I had mckoidb.jar in the path and not both mckjdbc.jar and mckoidb.jar.
The first thing I did was create the database from within my create schema program. This worked fine..
by using a URL with ?create=true option.

After the database was created, the create schema program exited. Now I have another Java program (say prog2) that is trying to
access the new schema created. I get the Journal file already exists problem. After looking for where I was making a mistake,
I tried to eliminate in-advertant starting of the database by removing all mckoi jar files from the path
and including the com.mckoi.* code in my project. So, I created the database again with mckoi code compiled into my project.
Now if I try to run my other program I see the same problem. Obviously I am starting another program somewhere... that I do not
know of.

To test and see if I get the same problem while running the database outside the IDE, I ran the following commands

> java -jar lib\mckoidb.jar -conf conf\db.conf
Mckoi SQL Database ( 1.0.2 )
Copyright (C) 2000, 2001, 2002, 2003 Diehl and Associates, Inc. All rights reserved.
Use: -h for help.

Mckoi SQL Database comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See LICENSE.txt for details of the
GPL License.

TCP JDBC Server (multi_threaded) on port: 9157.
Boot time: 1094ms.


and the query tool as follows

>java -cp lib\mckoidb.jar com.mckoi.tools.JDBCQueryTool -conf conf\db.conf -u "mw" -p "osx"
Using JDBC Driver: com.mckoi.JDBCDriver
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(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.mckoi.tools.JDBCQueryTool.main(JDBCQueryTool.java:357)

This is very puzzling since I created the database using the above userId and password. How do we get around this problem? Is there a master userId other than what we use to
create the database that we can use to see what values are stored in the database? When I step through the code, in the method com.mckoi.database.Database::authenticateUser
the select returns nothing, even though I used mw/osx to create the database. I am curious why?

Did I make any sense?

thanks

上面的是我在网上搜的 ,他的问题跟我的差不多
我执行完 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);

}

}
回复

回到 “C/C++/Java”