当前位置: 首页>>代码示例>>Java>>正文


Java DatabaseMetaData.getProcedures方法代码示例

本文整理汇总了Java中java.sql.DatabaseMetaData.getProcedures方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseMetaData.getProcedures方法的具体用法?Java DatabaseMetaData.getProcedures怎么用?Java DatabaseMetaData.getProcedures使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.sql.DatabaseMetaData的用法示例。


在下文中一共展示了DatabaseMetaData.getProcedures方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getStoredProceduresList

import java.sql.DatabaseMetaData; //导入方法依赖的package包/类
public ArrayList<SQLClauseSPInfo> getStoredProceduresList(DbConnectionBase dbConnection)
{
	ArrayList<SQLClauseSPInfo> arr = new ArrayList<SQLClauseSPInfo>();
	try
	{
		DatabaseMetaData dmd = dbConnection.getDbConnection().getMetaData();
		ResultSet rsProcs = dmd.getProcedures(null, null, "%");
		boolean b = true;
		while(rsProcs.next() && b)
		{
			SQLClauseSPInfo info = new SQLClauseSPInfo();
			if(info.fill(rsProcs))
				arr.add(info);
		}
	}
	catch (SQLException e)
	{
		return null;
	}
	return arr;	
}
 
开发者ID:costea7,项目名称:ChronoBike,代码行数:22,代码来源:SQLClauseSPSupport.java

示例2: testGetProceduresUsingInfoSchema

import java.sql.DatabaseMetaData; //导入方法依赖的package包/类
/**
 * Tests the implementation of Information Schema for description
 * of stored procedures available in a catalog.
 */
public void testGetProceduresUsingInfoSchema() throws Exception {
    if (versionMeetsMinimum(5, 0, 7)) {
        createProcedure("sp1", "()\n BEGIN\nSELECT 1;end\n");
        Properties props = new Properties();
        props.put("useInformationSchema", "true");
        Connection conn1 = null;
        try {
            conn1 = getConnectionWithProps(props);
            DatabaseMetaData metaData = conn1.getMetaData();
            this.rs = metaData.getProcedures(null, null, "sp1");
            this.rs.next();
            assertEquals("sp1", this.rs.getString("PROCEDURE_NAME"));
            assertEquals("1", this.rs.getString("PROCEDURE_TYPE"));
        } finally {
            if (conn1 != null) {
                conn1.close();
            }
        }
    }
}
 
开发者ID:Jugendhackt,项目名称:OpenVertretung,代码行数:25,代码来源:MetadataTest.java

示例3: checkGetProceduresForBug69298

import java.sql.DatabaseMetaData; //导入方法依赖的package包/类
private void checkGetProceduresForBug69298(String stepDescription, Connection testConn) throws Exception {
    DatabaseMetaData testDbMetaData = testConn.getMetaData();
    ResultSet proceduresMD = testDbMetaData.getProcedures(null, null, "testBug69298_%");
    String sd = stepDescription + " getProcedures() ";

    assertTrue(sd + "1st of 2 rows expected.", proceduresMD.next());

    // function: testBug69298_func
    assertEquals(sd + "-> PROCEDURE_CAT", testConn.getCatalog(), proceduresMD.getString("PROCEDURE_CAT"));
    assertEquals(sd + "-> PROCEDURE_SCHEM", null, proceduresMD.getString("PROCEDURE_SCHEM"));
    assertEquals(sd + "-> PROCEDURE_NAME", "testBug69298_func", proceduresMD.getString("PROCEDURE_NAME"));
    assertEquals(sd + "-> REMARKS", "testBug69298_func comment", proceduresMD.getString("REMARKS"));
    assertEquals(sd + "-> PROCEDURE_TYPE", DatabaseMetaData.procedureReturnsResult, proceduresMD.getShort("PROCEDURE_TYPE"));

    assertTrue(sd + "2nd of 2 rows expected.", proceduresMD.next());

    // procedure: testBug69298_proc
    assertEquals(sd + "-> PROCEDURE_CAT", testConn.getCatalog(), proceduresMD.getString("PROCEDURE_CAT"));
    assertEquals(sd + "-> PROCEDURE_SCHEM", null, proceduresMD.getString("PROCEDURE_SCHEM"));
    assertEquals(sd + "-> PROCEDURE_NAME", "testBug69298_proc", proceduresMD.getString("PROCEDURE_NAME"));
    assertEquals(sd + "-> REMARKS", "testBug69298_proc comment", proceduresMD.getString("REMARKS"));
    assertEquals(sd + "-> PROCEDURE_TYPE", DatabaseMetaData.procedureNoResult, proceduresMD.getShort("PROCEDURE_TYPE"));

    assertFalse(stepDescription + "no more rows expected.", proceduresMD.next());
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:26,代码来源:MetaDataRegressionTest.java

示例4: 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;

    // getProcedures() must return 2 records, even if getProceduresReturnsFunctions is false once this flag only
    // applies to JDBC4. When exists a procedure and a function with same name, function is returned first.
    sd = stepDescription + " getProcedures() ";
    rsMD = testDbMetaData.getProcedures(null, null, "testBug17248345");
    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());
    assertEquals(sd + " -> PROCEDURE_NAME", "testBug17248345", rsMD.getString("PROCEDURE_NAME"));
    assertFalse(sd + "no more rows expected.", rsMD.next());

    // getProcedureColumns() must return 3 records, even if getProceduresReturnsFunctions is false once this flag
    // only applies to JDBC4. When exists a procedure and a function with same name, function is returned first.
    sd = stepDescription + " getProcedureColumns() ";
    rsMD = testDbMetaData.getProcedureColumns(null, null, "testBug17248345", "%");
    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());
    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());
}
 
开发者ID:rafallis,项目名称:BibliotecaPS,代码行数:34,代码来源:MetaDataRegressionTest.java

示例5: checkGetProceduresForBug69298

import java.sql.DatabaseMetaData; //导入方法依赖的package包/类
private void checkGetProceduresForBug69298(String stepDescription, Connection testConn) throws Exception {
    DatabaseMetaData testDbMetaData = testConn.getMetaData();
    ResultSet proceduresMD = testDbMetaData.getProcedures(null, null, "testBug69298_%");
    String sd = stepDescription + " getProcedures() ";
    boolean isGetProceduresReturnsFunctions = ((ConnectionProperties) testConn).getGetProceduresReturnsFunctions();

    if (isGetProceduresReturnsFunctions) {
        assertTrue(sd + "1st of 2 rows expected.", proceduresMD.next());

        // function: testBug69298_func
        assertEquals(sd + "-> PROCEDURE_CAT", testConn.getCatalog(), proceduresMD.getString("PROCEDURE_CAT"));
        assertEquals(sd + "-> PROCEDURE_SCHEM", null, proceduresMD.getString("PROCEDURE_SCHEM"));
        assertEquals(sd + "-> PROCEDURE_NAME", "testBug69298_func", proceduresMD.getString("PROCEDURE_NAME"));
        assertEquals(sd + "-> REMARKS", "testBug69298_func comment", proceduresMD.getString("REMARKS"));
        assertEquals(sd + "-> PROCEDURE_TYPE", DatabaseMetaData.procedureReturnsResult, proceduresMD.getShort("PROCEDURE_TYPE"));
        assertEquals(sd + "-> SPECIFIC_NAME", "testBug69298_func", proceduresMD.getString("SPECIFIC_NAME"));

        assertTrue(sd + "2nd of 2 rows expected.", proceduresMD.next());
    } else {
        assertTrue(sd + "one row expected.", proceduresMD.next());
    }

    // procedure: testBug69298_proc
    assertEquals(sd + "-> PROCEDURE_CAT", testConn.getCatalog(), proceduresMD.getString("PROCEDURE_CAT"));
    assertEquals(sd + "-> PROCEDURE_SCHEM", null, proceduresMD.getString("PROCEDURE_SCHEM"));
    assertEquals(sd + "-> PROCEDURE_NAME", "testBug69298_proc", proceduresMD.getString("PROCEDURE_NAME"));
    assertEquals(sd + "-> REMARKS", "testBug69298_proc comment", proceduresMD.getString("REMARKS"));
    assertEquals(sd + "-> PROCEDURE_TYPE", DatabaseMetaData.procedureNoResult, proceduresMD.getShort("PROCEDURE_TYPE"));
    assertEquals(sd + "-> SPECIFIC_NAME", "testBug69298_proc", proceduresMD.getString("SPECIFIC_NAME"));

    assertFalse(stepDescription + "no more rows expected.", proceduresMD.next());
}
 
开发者ID:rafallis,项目名称:BibliotecaPS,代码行数:33,代码来源:MetaDataRegressionTest.java

示例6: 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);
}
 
开发者ID:syndesisio,项目名称:connectors,代码行数:9,代码来源:SqlStoredConnectorMetaDataExtension.java

示例7: 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();
    }
}
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:39,代码来源:TestDatabaseMetaData.java

示例8: 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))
		{
		}
	}
}
 
开发者ID:olavloite,项目名称:spanner-jdbc,代码行数:75,代码来源:MetaDataTester.java

示例9: 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());
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:60,代码来源:MetaDataRegressionTest.java


注:本文中的java.sql.DatabaseMetaData.getProcedures方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。