9

What is the correct syntax or what are the correct steps for creating a schema in DB2 using JDBC?

When running create schema test1 or create schema test1 authorization db2admin as db2admin, I consistently get DB2 SQL Error: SQLCODE=-552, SQLSTATE=42502, SQLERRMC=DB2ADMIN;CREATE SCHEMA, DRIVER=3.64.106

The exact same command works fine using the DB2 command-line tools.

2 Answers 2

9

I found it.

It turns out that for some reason DB2 Express-C does not grant the DBADM privilege to db2admin by default.

This can be fixed by connecting to the DB and then issuing

GRANT DBADM ON DATABASE to db2admin

Thanks Ian Bjorhovde for providing the inspiration spark!

Sign up to request clarification or add additional context in comments.

Comments

1

Looks like it is not a matter of Syntax but authentication, you have to check the credentials that you are passing through JDBC:

-552 authorization-id DOES NOT HAVE THE PRIVILEGE TO PERFORM OPERATION operation

http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.db2z9.doc.codes%2Fsrc%2Ftpc%2Fn552.htm

8 Comments

As I said, the user is DB2Admin and has all the rights. This same user can execute the statement with the DB2 command-line tools without problems.
I would try to narrow down the root cause, can you use another DB2 client and try to perform some DDL with the same credentials? java-source.net/open-source/sql-clients
Already did that. I also tried 3 different versions of the jdbc driver: an older one and the newest jdbc3 and jdbc4 ones. No luck.
So the next steps would be to try the same code against a fresh DB server and see what happens, it might give you some clues: www-01.ibm.com/software/data/db2/express-c/download.html
Please post the results of the query select dbadmauth from syscat.dbauth where grantee = current user when you are connected to the database as the user that is trying to execute CREATE SCHEMA
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.