Is it necessary to create tables each time you connect the derby database?

拜拜、爱过 提交于 2020-01-18 05:45:11

问题


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.


回答1:


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.


来源:https://stackoverflow.com/questions/22996818/is-it-necessary-to-create-tables-each-time-you-connect-the-derby-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!