开发者

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

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.

how to get table structre of a dat开发者_如何学运维abase in java?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜