This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Java Code does not recognize my sequence name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Java Code does not recognize my sequence name" Watch "Java Code does not recognize my sequence name" New topic
Author

Java Code does not recognize my sequence name

Srikanth Nittala
Greenhorn

Joined: Sep 24, 2006
Posts: 22
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

Joined: May 24, 2003
Posts: 425
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

Joined: Dec 20, 2006
Posts: 2476
    
    7

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


OCUP UML fundamental and ITIL foundation
youtube channel
Srikanth Nittala
Greenhorn

Joined: Sep 24, 2006
Posts: 22
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Code does not recognize my sequence name
 
Similar Threads
Prepared Statement
Does mysql3.2x.xx support Chinese?
Prepared Statement problem in my servlet's data manager
how to increase the number in oracle database automatically
Inserting date into an MS Access DB