本文整理匯總了Java中java.sql.DatabaseMetaData.getBestRowIdentifier方法的典型用法代碼示例。如果您正苦於以下問題:Java DatabaseMetaData.getBestRowIdentifier方法的具體用法?Java DatabaseMetaData.getBestRowIdentifier怎麽用?Java DatabaseMetaData.getBestRowIdentifier使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.sql.DatabaseMetaData
的用法示例。
在下文中一共展示了DatabaseMetaData.getBestRowIdentifier方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testBug8803
import java.sql.DatabaseMetaData; //導入方法依賴的package包/類
/**
* Tests fix for BUG#8803, 'DATA_TYPE' column from
* DBMD.getBestRowIdentifier() causes ArrayIndexOutOfBoundsException when
* accessed (and in fact, didn't return any value).
*
* @throws Exception
* if the test fails.
*/
public void testBug8803() throws Exception {
String tableName = "testBug8803";
createTable(tableName, "(field1 INT NOT NULL PRIMARY KEY)");
DatabaseMetaData metadata = this.conn.getMetaData();
try {
this.rs = metadata.getBestRowIdentifier(this.conn.getCatalog(), null, tableName, DatabaseMetaData.bestRowNotPseudo, true);
assertTrue(this.rs.next());
this.rs.getInt("DATA_TYPE"); // **** Fails here *****
} finally {
if (this.rs != null) {
this.rs.close();
this.rs = null;
}
}
}
示例2: testGetBestRowIdentifier
import java.sql.DatabaseMetaData; //導入方法依賴的package包/類
@Test public void testGetBestRowIdentifier() throws SQLException {
DatabaseMetaData metadata = getDatabaseMetadata();
try (ResultSet rs = metadata.getBestRowIdentifier(null, null, null,
DatabaseMetaData.bestRowUnknown, false)) {
ResultSetMetaData rsMeta = rs.getMetaData();
assertEquals(8, rsMeta.getColumnCount());
assertColumn(rsMeta, 1, "SCOPE", Types.SMALLINT, DatabaseMetaData.columnNoNulls);
assertColumn(rsMeta, 2, "COLUMN_NAME", Types.VARCHAR, DatabaseMetaData.columnNoNulls);
assertColumn(rsMeta, 3, "DATA_TYPE", Types.INTEGER, DatabaseMetaData.columnNoNulls);
assertColumn(rsMeta, 4, "TYPE_NAME", Types.VARCHAR, DatabaseMetaData.columnNoNulls);
assertColumn(rsMeta, 5, "COLUMN_SIZE", Types.INTEGER, DatabaseMetaData.columnNullable);
assertColumn(rsMeta, 6, "BUFFER_LENGTH", Types.INTEGER,
DatabaseMetaData.columnNullableUnknown);
assertColumn(rsMeta, 7, "DECIMAL_DIGITS", Types.SMALLINT, DatabaseMetaData.columnNullable);
assertColumn(rsMeta, 8, "PSEUDO_COLUMN", Types.SMALLINT, DatabaseMetaData.columnNoNulls);
}
}
示例3: testTwo
import java.sql.DatabaseMetaData; //導入方法依賴的package包/類
/**
* Basic test of DatabaseMetaData functions that access system tables
*/
public void testTwo() throws Exception {
Connection conn = newConnection();
int updateCount;
try {
TestUtil.testScript(conn, "testrun/hsqldb/TestSelf.txt");
DatabaseMetaData dbmeta = conn.getMetaData();
dbmeta.allProceduresAreCallable();
dbmeta.getBestRowIdentifier(null, null, "T_1",
DatabaseMetaData.bestRowTransaction,
true);
dbmeta.getCatalogs();
dbmeta.getColumnPrivileges(null, "PUBLIC", "T_1", "%");
dbmeta.getColumns("PUBLIC", "PUBLIC", "T_1", "%");
dbmeta.getCrossReference(null, null, "T_1", null, null, "T_1");
dbmeta.getExportedKeys(null, null, "T_1");
dbmeta.getFunctionColumns(null, "%", "%", "%");
dbmeta.getFunctions(null, "%", "%");
dbmeta.getImportedKeys("PUBLIC", "PUBLIC", "T_1");
dbmeta.getIndexInfo("PUBLIC", "PUBLIC", "T1", true, true);
dbmeta.getPrimaryKeys("PUBLIC", "PUBLIC", "T_1");
dbmeta.getProcedureColumns(null, null, "%", "%");
dbmeta.getProcedures("PUBLIC", "%", "%");
dbmeta.getSchemas(null, "#");
dbmeta.getTablePrivileges(null, "%", "%");
dbmeta.getUDTs(null, "%", "%", new int[]{ Types.DISTINCT });
} catch (Exception e) {
assertTrue("unable to prepare or execute DDL", false);
} finally {
conn.close();
}
}
示例4: runOtherMetaDataTests
import java.sql.DatabaseMetaData; //導入方法依賴的package包/類
private void runOtherMetaDataTests() throws SQLException
{
DatabaseMetaData metadata = connection.getMetaData();
try (ResultSet rs = metadata.getCatalogs())
{
}
try (ResultSet rs = metadata.getAttributes("", "", null, null))
{
}
try (ResultSet rs = metadata.getClientInfoProperties())
{
}
try (ResultSet rs = metadata.getFunctionColumns("", "", null, null))
{
}
try (ResultSet rs = metadata.getFunctions("", "", null))
{
}
try (ResultSet rs = metadata.getProcedureColumns("", "", null, null))
{
}
try (ResultSet rs = metadata.getProcedures("", "", null))
{
}
try (ResultSet rs = metadata.getSchemas())
{
}
try (ResultSet rs = metadata.getSchemas("", null))
{
}
try (ResultSet rs = metadata.getSuperTypes("", "", null))
{
}
try (ResultSet rs = metadata.getTableTypes())
{
}
try (ResultSet rs = metadata.getTypeInfo())
{
}
try (ResultSet rs = metadata.getUDTs(null, null, null, null))
{
}
for (String table : TABLES)
{
try (ResultSet rs = metadata.getExportedKeys("", "", table))
{
}
try (ResultSet rs = metadata.getImportedKeys("", "", table))
{
}
try (ResultSet rs = metadata.getBestRowIdentifier("", "", table, DatabaseMetaData.bestRowTransaction,
false))
{
}
try (ResultSet rs = metadata.getColumnPrivileges("", "", table, null))
{
}
try (ResultSet rs = metadata.getPrimaryKeys("", "", table))
{
}
try (ResultSet rs = metadata.getPseudoColumns("", "", table, null))
{
}
try (ResultSet rs = metadata.getSuperTables("", "", table))
{
}
try (ResultSet rs = metadata.getTablePrivileges("", "", table))
{
}
try (ResultSet rs = metadata.getVersionColumns("", "", table))
{
}
}
}