Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1520
  • Last Modified:

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
0
Anthony Lucia
Asked:
Anthony Lucia
1 Solution
 
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

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now