本文介绍了删除TAble(如果存在),然后创建表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ms Access数据库创建Java应用程序.

i am creating java application using ms access database.

我必须创建表"student"(如果不存在则退出,如果存在则先删除表,然后使表成为学生).

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

我正在为此编写代码.为此,我已经使函数boolean makeTable(Connection con,String tablename)和函数boolean dropTable(Connection con,String tablename)

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)

第一次如果存在表,则maketable()返回false,然后调用函数dropTable(),它也返回false(未删除表)

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

第二次 调用dropTable()然后返回true(表已成功删除),然后调用createTable()返回false(未创建表).

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.

请帮助这个.

如果有语句(如果存在学生,则删除表)或其他方式做到这一点

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

提前谢谢.

-PARAG HUMANE

--PARAG HUMANE

推荐答案

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

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

这篇关于删除TAble(如果存在),然后创建表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 20:54
查看更多