• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Code does not recognize my sequence name

 
Srikanth Nittala
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,i have a strange problem. My sequence name is not getting recognized inside my insert statement written in String inside my DAO. I am sure the sequence name is right because i executed "select sws_user_sequence.currval from dual" gives me the right value in sql Developer tool. Only thru the java code as written below, the compiler throws a sql exception ORA-02289: sequence does not exist. Here is the code.
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If sequence exists for sure then it must be privilege issue. See what userid or schema is used when creating the connection. I am sure the user used for creating connection doesn't have right privilege (SELECT ANY SEQUENCE)
 
Jan Cumps
Bartender
Posts: 2599
12
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Addition to comment of Purushothaman:

If you are running your java code as an other user, it might help to put the schema name in front of the sequence name:

....VALUES(SCOTT.sws_user_sequence.nextval,....

It might not be necessary to add new privileges.

Regards, Jan
 
Srikanth Nittala
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help. Indeed it turned out to be privileges issue. There were some synonyms created for the tables in the schema and those were messed up.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic