本文整理汇总了Java中java.sql.DatabaseMetaData.getFunctions方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseMetaData.getFunctions方法的具体用法?Java DatabaseMetaData.getFunctions怎么用?Java DatabaseMetaData.getFunctions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.DatabaseMetaData
的用法示例。
在下文中一共展示了DatabaseMetaData.getFunctions方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkGetFunctionsForBug69298
import java.sql.DatabaseMetaData; //导入方法依赖的package包/类
private void checkGetFunctionsForBug69298(String stepDescription, Connection testConn) throws Exception {
DatabaseMetaData testDbMetaData = testConn.getMetaData();
ResultSet functionsMD = testDbMetaData.getFunctions(null, null, "testBug69298_%");
String sd = stepDescription + " getFunctions() ";
assertTrue(sd + "one row expected.", functionsMD.next());
// function: testBug69298_func
assertEquals(sd + "-> FUNCTION_CAT", testConn.getCatalog(), functionsMD.getString("FUNCTION_CAT"));
assertEquals(sd + "-> FUNCTION_SCHEM", null, functionsMD.getString("FUNCTION_SCHEM"));
assertEquals(sd + "-> FUNCTION_NAME", "testBug69298_func", functionsMD.getString("FUNCTION_NAME"));
assertEquals(sd + "-> REMARKS", "testBug69298_func comment", functionsMD.getString("REMARKS"));
assertEquals(sd + "-> FUNCTION_TYPE", DatabaseMetaData.functionNoTable, functionsMD.getShort("FUNCTION_TYPE"));
assertEquals(sd + "-> SPECIFIC_NAME", "testBug69298_func", functionsMD.getString("SPECIFIC_NAME"));
assertFalse(stepDescription + "no more rows expected.", functionsMD.next());
}
示例2: getFunctions
import java.sql.DatabaseMetaData; //导入方法依赖的package包/类
/**
* Call {@link DatabaseMetaData#geFunctions(String, String, String)},
* wrapping any internal runtime exception into an {@link SQLException}.
*/
public static ResultSet getFunctions(DatabaseMetaData dmd,
String catalog, String schemaPattern, String functionNamePattern)
throws SQLException {
try {
return dmd.getFunctions(catalog, schemaPattern,
functionNamePattern);
} catch (SQLException e) {
throw e;
} catch (Throwable t) {
throw new SQLException(t);
}
}
示例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: fetchProcedures
import java.sql.DatabaseMetaData; //导入方法依赖的package包/类
public static ResultSet fetchProcedures(final DatabaseMetaData meta, final String catalog,
final String schemaPattern, final String procedurePattern) throws SQLException {
if (meta.getDatabaseProductName().equalsIgnoreCase(DatabaseProduct.POSTGRESQL.name())) {
return meta.getFunctions(catalog, schemaPattern, procedurePattern);
}
return meta.getProcedures(catalog, schemaPattern, procedurePattern);
}
示例5: fetchProcedures
import java.sql.DatabaseMetaData; //导入方法依赖的package包/类
static ResultSet fetchProcedures(final DatabaseMetaData meta, final String catalog,
final String schemaPattern, final String procedurePattern) throws SQLException {
if (meta.getDatabaseProductName().equalsIgnoreCase(DatabaseProduct.POSTGRESQL.name())) {
return meta.getFunctions(catalog, schemaPattern, procedurePattern);
}
return meta.getProcedures(catalog, schemaPattern, procedurePattern);
}
示例6: testGetFunctions
import java.sql.DatabaseMetaData; //导入方法依赖的package包/类
@Test public void testGetFunctions() throws SQLException {
DatabaseMetaData metadata = getDatabaseMetadata();
try (ResultSet rs = metadata.getFunctions(null, null, null)) {
ResultSetMetaData rsMeta = rs.getMetaData();
assertEquals(6, rsMeta.getColumnCount());
assertColumn(rsMeta, 1, "FUNCTION_CAT", Types.VARCHAR, DatabaseMetaData.columnNullable);
assertColumn(rsMeta, 2, "FUNCTION_SCHEM", Types.VARCHAR, DatabaseMetaData.columnNullable);
assertColumn(rsMeta, 3, "FUNCTION_NAME", Types.VARCHAR, DatabaseMetaData.columnNoNulls);
assertColumn(rsMeta, 4, "REMARKS", Types.VARCHAR, DatabaseMetaData.columnNullable);
assertColumn(rsMeta, 5, "FUNCTION_TYPE", Types.SMALLINT, DatabaseMetaData.columnNoNulls);
assertColumn(rsMeta, 6, "SPECIFIC_NAME", Types.VARCHAR, DatabaseMetaData.columnNullable);
}
}
示例7: 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))
{
}
}
}
示例8: checkMetaDataInfoForBug17248345
import java.sql.DatabaseMetaData; //导入方法依赖的package包/类
private void checkMetaDataInfoForBug17248345(Connection testConn) throws Exception {
DatabaseMetaData testDbMetaData = testConn.getMetaData();
ResultSet rsMD;
boolean useInfoSchema = ((ConnectionProperties) testConn).getUseInformationSchema();
boolean getProcRetFunc = ((ConnectionProperties) testConn).getGetProceduresReturnsFunctions();
String stepDescription = "Prop. useInfoSchema(" + (useInfoSchema ? 1 : 0) + ") + getProcRetFunc(" + (getProcRetFunc ? 1 : 0) + "):";
String sd;
// getFunctions() must return 1 record.
sd = stepDescription + " getFunctions() ";
rsMD = testDbMetaData.getFunctions(null, null, "testBug17248345");
assertTrue(sd + "one row expected.", rsMD.next());
assertEquals(sd + " -> FUNCTION_NAME", "testBug17248345", rsMD.getString("FUNCTION_NAME"));
assertFalse(sd + "no more rows expected.", rsMD.next());
// getFunctionColumns() must return 2 records (func return + func param).
sd = stepDescription + " getFunctionColumns() ";
rsMD = testDbMetaData.getFunctionColumns(null, null, "testBug17248345", "%");
assertTrue(sd + "1st of 2 rows expected.", rsMD.next());
assertEquals(sd + " -> FUNCTION_NAME", "testBug17248345", rsMD.getString("FUNCTION_NAME"));
assertEquals(sd + " -> COLUMN_NAME", "", rsMD.getString("COLUMN_NAME"));
assertTrue(sd + "2nd of 2 rows expected.", rsMD.next());
assertEquals(sd + " -> FUNCTION_NAME", "testBug17248345", rsMD.getString("FUNCTION_NAME"));
assertEquals(sd + " -> COLUMN_NAME", "funccol", rsMD.getString("COLUMN_NAME"));
assertFalse(sd + "no more rows expected.", rsMD.next());
// getProcedures() must return 1 or 2 records, depending on if getProceduresReturnsFunctions is false or true
// respectively. When exists a procedure and a function with same name, function is returned first.
sd = stepDescription + " getProcedures() ";
rsMD = testDbMetaData.getProcedures(null, null, "testBug17248345");
if (getProcRetFunc) {
assertTrue(sd + "1st of 2 rows expected.", rsMD.next());
assertEquals(sd + " -> PROCEDURE_NAME", "testBug17248345", rsMD.getString("PROCEDURE_NAME"));
assertTrue(sd + "2nd of 2 rows expected.", rsMD.next());
} else {
assertTrue(sd + "one row expected.", rsMD.next());
}
assertEquals(sd + " -> PROCEDURE_NAME", "testBug17248345", rsMD.getString("PROCEDURE_NAME"));
assertFalse(sd + "no more rows expected.", rsMD.next());
// getProcedureColumns() must return 1 or 3 records, depending on if getProceduresReturnsFunctions is false or
// true respectively. When exists a procedure and a function with same name, function is returned first.
sd = stepDescription + " getProcedureColumns() ";
rsMD = testDbMetaData.getProcedureColumns(null, null, "testBug17248345", "%");
if (getProcRetFunc) {
assertTrue(sd + "1st of 3 rows expected.", rsMD.next());
assertEquals(sd + " -> PROCEDURE_NAME", "testBug17248345", rsMD.getString("PROCEDURE_NAME"));
assertEquals(sd + " -> COLUMN_NAME", "", rsMD.getString("COLUMN_NAME"));
assertTrue(sd + "2nd of 3 rows expected.", rsMD.next());
assertEquals(sd + " -> PROCEDURE_NAME", "testBug17248345", rsMD.getString("PROCEDURE_NAME"));
assertEquals(sd + " -> COLUMN_NAME", "funccol", rsMD.getString("COLUMN_NAME"));
assertTrue(sd + "3rd of 3 rows expected.", rsMD.next());
} else {
assertTrue(sd + "one row expected.", rsMD.next());
}
assertEquals(sd + " -> PROCEDURE_NAME", "testBug17248345", rsMD.getString("PROCEDURE_NAME"));
assertEquals(sd + " -> COLUMN_NAME", "proccol", rsMD.getString("COLUMN_NAME"));
assertFalse(sd + "no more rows expected.", rsMD.next());
}