Pregunta

I created a schema and few tables manually using the Eclipse database development perspective. But whenever I try to access the table from code, I get "Schema does not exist" error. However, if I create the tables within my program just before using them, all go well. Do I have to create the tables each time I connect to database? Since, I am testing my code, I have to restart the project multiple times.

¿Fue útil?

Solución

Three common reasons for "table does not exist" when you think you've already created the tables:

  1. You are connecting to a different database than you think you were connecting to, and since you specified "create=true" on the Connection URL, Derby quietly created a new empty database for you.
  2. You are using the "in-memory" configuration of Derby, which means that when the database is closed (or your application exits), all the contents of the database disappear.
  3. You are connecting to the database as a different user, and you aren't issuing the SET SCHEMA statement, so you are using the default schema name, which is based on your user name, and so the two schemas are different and have completely different tables, so the table you created doesn't seem to exist when you use the other schema.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top