如果存在则删除表,然后创建表

发布于 2024-12-07 03:27:35 字数 505 浏览 2 评论 0原文

我正在使用 MS Access 数据库创建 Java 应用程序。

我必须创建表“学生”,如果不退出,如果存在,则先删除表,然后创建表学生。

我已经为它编写了代码。为此,我

第一次 制作了函数 boolean makeTable(Connection con,String tablename) 和 function boolean dropTable (Connection con,String tablename) 如果存在表,则 maketable() 返回 false,但然后调用函数 dropTable() 它也返回 false(表未删除

) 调用 dropTable() 然后返回 true(表删除成功),但然后调用 createTable() 返回 false(表未创建)。

我不知道为什么会发生这种情况。

请帮忙这个。

如果有语句(Drop Table IF EXIST STUDENT) 或其他方式

提前致谢。

——帕拉格·人道

i am creating java application using ms access database.

i have to create table "student" if not exit and if exist then drop table first then make table student.

i have writing code for it. for this i have made function boolean makeTable(Connection con,String tablename) and function boolean dropTable (Connection con,String tablename)

First time
if exist table then maketable() return false but then call function dropTable() it return false also(table not deleted)

second time
call dropTable() then return true (table deleted successfully) but then call createTable() return false (table not created).

why this happens i don't know.

please help this.

if there is statement (Drop Table IF EXIST STUDENT)
or other way to doing this

thanks in advance.

--PARAG HUMANE

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独夜无伴 2024-12-14 03:27:35

使用 Connection.getMetaData().getTables() 方法。它返回表描述。

Use Connection.getMetaData().getTables() method. It return tables description.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文