Add the metadata acquisition of index info.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@1438 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: JDBCUtil.java,v 1.8 2004/05/17 15:58:45 mdb Exp $
|
// $Id: JDBCUtil.java,v 1.9 2004/05/27 02:04:34 eric Exp $
|
||||||
//
|
//
|
||||||
// samskivert library - useful routines for java programs
|
// samskivert library - useful routines for java programs
|
||||||
// Copyright (C) 2001 Michael Bayne
|
// Copyright (C) 2001 Michael Bayne
|
||||||
@@ -183,6 +183,29 @@ public class JDBCUtil
|
|||||||
return matched;
|
return matched;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the index on the specified column exists for the
|
||||||
|
* specified table. false if it does not. <em>Note:</em> the names are
|
||||||
|
* case sensitive.
|
||||||
|
*/
|
||||||
|
public static boolean tableContainsIndex (Connection conn, String table,
|
||||||
|
String column)
|
||||||
|
throws SQLException
|
||||||
|
{
|
||||||
|
boolean matched = false;
|
||||||
|
ResultSet rs = conn.getMetaData().getIndexInfo("", "", table, false,
|
||||||
|
true);
|
||||||
|
while (rs.next()) {
|
||||||
|
String tname = rs.getString("TABLE_NAME");
|
||||||
|
String cname = rs.getString("COLUMN_NAME");
|
||||||
|
if (tname.equals(table) && cname.equals(column)) {
|
||||||
|
matched = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return matched;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the table with the specified name exists and
|
* Returns true if the table with the specified name exists and
|
||||||
* contains a column with the specified name, false if either
|
* contains a column with the specified name, false if either
|
||||||
|
|||||||
Reference in New Issue
Block a user