在Java中显示数据库表 [英] Display tables of a database in java

查看:284
本文介绍了在Java中显示数据库表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Java应用程序,并且想在Mysql数据库中显示表的列表,我在网上搜索了一下,发现"SHOW TABLES FROM [DB]"是适当的请求,但是我如何在Java swing/awt应用程序上显示此最后的结果, PS:我试图将请求的结果放到结果集上,

I'm working on a java application, and I want to display the list of the tables in a Mysql database, I searched on the net and I found that "SHOW TABLES FROM [DB]" is the appropriate request, but how can I dispaly the result of this last on a java swing/awt application, PS : I tried to put the result of the request on a resultset,

res = sta.executeQuery("SHOW TABLES FROM sinpec ");

但它不起作用...

我该如何进行?

推荐答案

请尝试以下查询:-

SELECT TABLE_NAME 
FROM INFORMATION_SCHEMA.TABLES 
WHERE table_schema = "DATABASE_NAME"

这篇关于在Java中显示数据库表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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