/** * Check if a stored database procedure exists. * * @param dmd the meta-data object used for checking * @param schema the procedure's schema * @param proc the name of the procedure * @return {@code true} if the procedure exists, {@code false} otherwise * @throws SQLException if an error happens when reading the meta-data */ private boolean procedureExists(DatabaseMetaData dmd, String schema, String proc) throws SQLException { try (ResultSet rs = dmd.getProcedures(null, schema, proc)) { // If there's a row, there is such a procedure. return rs.next(); } }
/** 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(); } }
public ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) throws SQLException { _conn.checkOpen(); try { return DelegatingResultSet.wrapResultSet( _conn, _meta.getProcedures(catalog, schemaPattern, procedureNamePattern)); } catch (SQLException e) { handleException(e); throw new AssertionError(); } }
@Test public void columnOrderOfgetProcedures() throws SQLException { ResultSet rs = meta.getProcedures(null, null, null); assertFalse(rs.next()); ResultSetMetaData rsmeta = rs.getMetaData(); assertEquals(rsmeta.getColumnCount(), 8); assertEquals(rsmeta.getColumnName(1), "PROCEDURE_CAT"); assertEquals(rsmeta.getColumnName(2), "PROCEDURE_SCHEM"); assertEquals(rsmeta.getColumnName(3), "PROCEDURE_NAME"); // currently (Java 1.5), cols 4,5,6 are undefined assertEquals(rsmeta.getColumnName(7), "REMARKS"); assertEquals(rsmeta.getColumnName(8), "PROCEDURE_TYPE"); }
@Test public void testProcedures() throws Exception { TestMMDatabaseMetaData.compareResultSet( dbMetadata.getProcedures(VDB, null, "%")); // $NON-NLS-1$ //$NON-NLS-2$ }
public ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) throws SQLException { return throwExceptionDelegate.getProcedures(catalog, schemaPattern, procedureNamePattern); }