java.sql.DatabaseMetaData metadata = db.getMetaData();//db为一个connection
ResultSet rs = metadata.getExportedKeys(null, null, tablename);//获得某个表的metadata
String foreigntablename = rs.getString(7);//从 1到16 你依次试试,就知道各个的含义了,另外也可以自己直接查api,看是什么... 7是外键的表名,其他有字段名等等等等
ResultSet rs = metadata.getExportedKeys(null, null, tablename);//获得某个表的metadata
String foreigntablename = rs.getString(7);//从 1到16 你依次试试,就知道各个的含义了,另外也可以自己直接查api,看是什么... 7是外键的表名,其他有字段名等等等等
解决方案 »
- 如何在Frame里头加上图片作为背景,高手请进,在线等!
- 急!!!跨域cookie的域名可以被改变吗?急!!!
- 请教:关于JTable的问题~~急
- 求高人指点是否是死锁的问题~怎么运行为空呢
- 一个取得数据库记录的问题,请大家帮着看看
- tomcat 和 apache整合问题
- 能运行HelloWorld但是不能运行Receive呢,提示:Exception in thread "main" java.lang.NoClassDefFoundError(60)
- 讨论:JXL、POI调用EXCEL模板实现web打印的问题?大家都关心的问题。
- 一个菜鸟问题:如何创建一个固定大小的frame
- 请问怎么样对JTextArea文本添加新的文本?谢谢
- 请问用java如何取得当前系统的光驱盘符?
- 送分就是爽继续:)
1。getPrimaryKeys(String catalog, String schema, String table)
Retrieves a description of the given table's primary key columns
得到主键2。getImportedKeys(String catalog, String schema, String table)
Retrieves a description of the primary key columns that are referenced by a table's foreign key columns (the primary keys imported by a table)
得到和表主键相关的所有外键3。getCrossReference(String primaryCatalog, String primarySchema, String primaryTable, String foreignCatalog, String foreignSchema, String foreignTable)
Retrieves a description of the foreign key columns in the given foreign key table that reference the primary key columns of the given primary key table (describe how one table imports another's key).