how to get table structre of a database in java? [closed]

旧城冷巷雨未停 提交于 2019-11-29 07:19:07

Use DatabaseMetaData to get the table information.

You can use the getTablexxx() and getColumnxx() methods to get the table information.

Connection conn = DriverManager.getConnection(.....);
DatabaseMetaData dbmd = conn.getMetaData();
dbmd.getxxxx(); 

If you just care about being able to recreate the table on a different server, you can use SHOW TABLES to get a list of tables, then SHOW CREATE TABLE foo to get the CREATE TABLE command. You might also look at the mysqldump program to see if it better suits your needs.

Joshua

One way is to use hibernate, reverse engineer and generate entity beans according to your existing database.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!