JDBC: SQLCODE 103 and SQLCODE 551

In all examples below, the instance name was replaced with 'xxx'.

From the CLP I can perform the following:

db2 => connect to TEST

   Database Connection Information

 Database server        = DB2/NT64 10.1.0
 SQL authorization ID   = xxx...
 Local database alias   = TEST

db2 =>
db2 => SELECT ACCTNUM FROM xxx.ACCOUNT

ACCTNUM
----------
11111
22222

  2 record(s) selected.

Open in new window


SO I go to the JDBC connection, with the following credentials:

jdbc:db2://localhost:50000/TEST:user=instuid;password=instpw;

Open in new window


and execute the following prepared statement:

SELECT ACCTNUM FROM xxx.ACCOUNT;

Open in new window


... and I get the following error (SQLCODE 104 apparently means that there is a problem with a character acting as a symbol):

DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=;;xxx.ACCOUNT;END
-OF-STATEMENT, DRIVER=3.63.123 (com.ibm.db2.jcc.am.SqlSyntaxErrorException). Mes
sage payload is of type: String

Open in new window


... so, just in case the trailing semi-colon is an illegal symbol, I tried the following (without trailing semi-colon):

SELECT ACCTNUM FROM xxx.ACCOUNT

Open in new window


... but now I get the following error.

DB2 SQL Error: SQLCODE=-551, SQLSTATE=42501, SQLERRMC=INSTUID;SELECT;xxx
.ACCOUNT, DRIVER=3.63.123 (com.ibm.db2.jcc.am.SqlSyntaxErrorException). Message
 payload is of type: String

Open in new window


Note I am using th efollowing jar:    db2jcc.jar

SQLCODE 551 apparently says that I need to grant some sort of privilege so that the comamnd can be processed statically (Prepared statement)

My questions:

1> Can I assume that in the first statement, the semei-colon end of statement was actually causing the problem, and that the SQLCODE of 551 is the real problem

2> How do I grant privileges so the JDBC (using the

Thanks
Anthony LuciaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

momi_sabagCommented:
-104 is due to the semi colon.
when using jdbc, don't use the semi colon (which is your way of telling the CLP where you sql statement ends)

-551 means lack of permissions, you will solve it by doing

connect to test

grant select on account to INSTUID;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
DB2

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.