0

I have sucessfully connected to my database through JDBC (no sid or service specified): com.test.sql.url=jdbc:oracle:thin://@111.222.333.444:1521, but when my java program tries to insert a row that uses a sequence I created, I get the error java.sql.SQLSyntaxErrorException: ORA-02289: sequence does not exist. I have verified in SQL developer that my sequences exist for my database user, so I'm thinking it is some kind of permissions issue? I initally created the user with sys as sysdba and then created a script that connected as the new user and created all the necessary tables and sequences. What am I missing here? Thanks.

5
  • What does your code look like? Commented May 14, 2013 at 2:57
  • @hol dbConnection.prepareStatement("select ticket_seq.NextVal from dual"); Commented May 14, 2013 at 3:08
  • Do you need to set the schema? like myschema.ticket_seq.next_val Commented May 14, 2013 at 3:12
  • @hol I have tried manually (not in my application) with the schema, but it still says sequence does not exist (with a * under the t so it cant find ticket_seq) I have double checked the names and the sequence ticket_seq is visible in sql developer to the same user/password that my application uses. But I cannot select from it either when I am in sqlplus. Commented May 14, 2013 at 3:21
  • Also interesting, sequence also does not exist when I run the command select userSchema.ticket_seq.nextval from dual with sys as sysdba. Commented May 14, 2013 at 3:27

1 Answer 1

1

I figured out the problem. It was actually a problem with my database creation script. I had created the sequence with CREATE SEQUENCE "ticket_seq" START WITH 10; so the double quotes enforced case sensitivity. I now know that Oracle tables/sequences, etc. are default case insensitive so the command select ticket_seq.nextval from dual was interpreted as SELECT TICKET_SEQ.NEXTVAL FROM DUAL and therefore my lowercase sequence could not be found. I removed the double quotes from my script and now I can find the sequence as expected.

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

Comments

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.