如果存在则删除表,然后创建表
我正在使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 Connection.getMetaData().getTables() 方法。它返回表描述。
Use Connection.getMetaData().getTables() method. It return tables description.