Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
693 views
in Technique[技术] by (71.8m points)

jdbc - Db2 connection problem with java

I am having problem with DB2. I just installed the db2 as a db2admin and with a password. When i try to connect to database it is success full and while running any simple select query it give me following error:-

DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=DB2ADMIN.LOGIN, DRIVER=3.57.82

I have a database named onp and a table in it called 'login' in which there is one table called 'login' with two fields username and password.

Query that i am running

  1. Select * from login; gives me error

DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=DB2ADMIN.LOGIN, DRIVER=3.57.82

  1. Select * from system.login; gives me error:- (//system is schema name)

DB2 SQL Error: SQLCODE=-551, SQLSTATE=42501, SQLERRMC=DB2ADMIN;SELECT;SYSTEM.LOGIN, DRIVER=3.57.82

I have tried all the resources on the net and exhausted completely. Please help me

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I don't know a lot about DB2, but looking up the error codes...

The first error is because you didn't specify a schema, so it couldn't find the login table.

SQLCODE -204 Object not defined to DB2

DB2 apparently requires you to specify the schema name or it looks in the schema with the same name as your login user.

You must use SET SCHEMA or fully qualify the table name.

The second error is because you don't have the privileges to perform that select:

SQLCODE -551, Error: DOES NOT HAVE THE PRIVILEGE TO PERFORM OPERATION ON OBJECT

I'm not sure why the db2admin user wouldn't be able to select from this table...

Resources:
List of DB2 SQLCODEs


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...