每次连接derby数据库都要建表吗? [英] Is it necessary to create tables each time you connect the derby database?

查看:26
本文介绍了每次连接derby数据库都要建表吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Eclipse 数据库开发透视图手动创建了一个模式和几个表.但是每当我尝试从代码访问表时,我都会收到架构不存在"错误.但是,如果我在使用它们之前在我的程序中创建表,一切顺利.每次连接到数据库时都必须创建表吗?因为,我正在测试我的代码,所以我必须多次重新启动项目.

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.

推荐答案

当您认为已经创建了表时,表不存在"的三个常见原因:

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

  1. 您连接的数据库与您认为连接的数据库不同,并且由于您在连接 URL 上指定了create=true",Derby 悄悄地为您创建了一个新的空数据库.
  2. 您正在使用 Derby 的内存中"配置,这意味着当数据库关闭(或您的应用程序退出)时,数据库的所有内容都会消失.
  3. 您以不同的用户身份连接到数据库,并且您没有发出 SET SCHEMA 语句,因此您使用的是基于您的用户名的默认架构名称,因此这两个架构不同并且有完全不同的表,因此当您使用其他架构时,您创建的表似乎不存在.

这篇关于每次连接derby数据库都要建表吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆