Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 821
RishiPatel Avatar asked Oct 19 '09 13:10

RishiPatel


People also ask

How do I fix error code DB2?

Fix: Qualify the ambiguous column name with a correct table name. If the SQL statement try to use INSERT , UPDATE or SELECT a column name which is not part of the table, then this DB2 SQL Error code is generated. ORDER BY clause in wrong because the column name is not a part of the result table .

What is JDBC driver for DB2?

JDBC drivers are Java library files with the extension . jar used by all Java applications to connect to the database. Usually, they are provided by the same company which implemented the Db2 software. DbSchema Tool already includes an Db2 driver, which is automatically downloaded when you connect to Db2.

Does DB2 need Java?

You require the appropriate level of IBM® Software Development Kit (SDK) for Java™ to use Java-based tools and to create and run Java applications, including stored procedures and user-defined functions.


2 Answers

I had the same problem and i resolved it by adding Schema in my entity :

@Entity
@Table(name="MyTable", schema="MySchemaName")
public class MyClass implements Serializable {
...
}
like image 65
ilias Avatar answered Oct 09 '22 10:10

ilias


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

like image 44
Powerlord Avatar answered Oct 09 '22 09:10

Powerlord