List of usage examples for java.sql DatabaseMetaData procedureReturnsResult
int procedureReturnsResult
To view the source code for java.sql DatabaseMetaData procedureReturnsResult.
Click Source Link
From source file:org.apache.cayenne.access.DbLoader.java
private Map<String, Procedure> loadProcedures(FiltersConfig filters, String catalog, String schema) throws SQLException { Map<String, Procedure> procedures = new HashMap<>(); // get procedures try (ResultSet rs = getMetaData().getProcedures(catalog, schema, WILDCARD);) { while (rs.next()) { String name = rs.getString("PROCEDURE_NAME"); Procedure procedure = new Procedure(name); procedure.setCatalog(rs.getString("PROCEDURE_CAT")); procedure.setSchema(rs.getString("PROCEDURE_SCHEM")); if (filters.proceduresFilter(procedure.getCatalog(), procedure.getSchema()) .isInclude(procedure.getName())) { LOGGER.info("skipping Cayenne PK procedure: " + name); continue; }/*from w ww.j a v a 2s . c o m*/ switch (rs.getShort("PROCEDURE_TYPE")) { case DatabaseMetaData.procedureNoResult: case DatabaseMetaData.procedureResultUnknown: procedure.setReturningValue(false); break; case DatabaseMetaData.procedureReturnsResult: procedure.setReturningValue(true); break; } procedures.put(procedure.getFullyQualifiedName(), procedure); } } return procedures; }
From source file:org.apache.cayenne.dbsync.reverse.db.DbLoader.java
private Map<String, Procedure> loadProcedures(FiltersConfig filters, String catalog, String schema) throws SQLException { Map<String, Procedure> procedures = new HashMap<>(); // get procedures try (ResultSet rs = getMetaData().getProcedures(catalog, schema, WILDCARD);) { while (rs.next()) { String name = rs.getString("PROCEDURE_NAME"); Procedure procedure = new Procedure(name); procedure.setCatalog(rs.getString("PROCEDURE_CAT")); procedure.setSchema(rs.getString("PROCEDURE_SCHEM")); if (!filters.proceduresFilter(procedure.getCatalog(), procedure.getSchema()) .isIncluded(procedure.getName())) { LOGGER.info("skipping Cayenne PK procedure: " + name); continue; }/* w ww.ja v a2s . c om*/ switch (rs.getShort("PROCEDURE_TYPE")) { case DatabaseMetaData.procedureNoResult: case DatabaseMetaData.procedureResultUnknown: procedure.setReturningValue(false); break; case DatabaseMetaData.procedureReturnsResult: procedure.setReturningValue(true); break; } procedures.put(procedure.getFullyQualifiedName(), procedure); } } return procedures; }
From source file:org.apache.cayenne.dbsync.reverse.dbload.ProcedureLoader.java
@Override protected void processResultSetRow(CatalogFilter catalog, SchemaFilter schema, DbLoadDataStore map, ResultSet rs) throws SQLException { PatternFilter filter = config.getFiltersConfig().proceduresFilter(catalog.name, schema.name); String name = rs.getString("PROCEDURE_NAME"); if (!filter.isIncluded(name)) { LOGGER.info("skipping Cayenne PK procedure: " + name); return;/*from w ww .j a va2 s. c o m*/ } Procedure procedure = new Procedure(name); procedure.setCatalog(rs.getString("PROCEDURE_CAT")); procedure.setSchema(rs.getString("PROCEDURE_SCHEM")); switch (rs.getShort("PROCEDURE_TYPE")) { case DatabaseMetaData.procedureNoResult: case DatabaseMetaData.procedureResultUnknown: procedure.setReturningValue(false); break; case DatabaseMetaData.procedureReturnsResult: procedure.setReturningValue(true); break; } map.addProcedureSafe(procedure); }
From source file:org.apache.ddlutils.task.DumpMetadataTask.java
/** * Dumps all procedures./*from www .j a va 2s. c o m*/ * * @param xmlWriter The xml writer to write to * @param metaData The database metadata */ private void dumpProcedures(PrettyPrintingXmlWriter xmlWriter, final DatabaseMetaData metaData) throws SQLException { performResultSetXmlOperation(xmlWriter, "procedures", new ResultSetXmlOperation() { public ResultSet getResultSet() throws SQLException { return metaData.getProcedures(_catalogPattern, _schemaPattern, _procedurePattern); } public void handleRow(PrettyPrintingXmlWriter xmlWriter, ResultSet result) throws SQLException { Set columns = getColumnsInResultSet(result); String procedureName = result.getString("PROCEDURE_NAME"); if ((procedureName != null) && (procedureName.length() > 0)) { String catalog = result.getString("PROCEDURE_CAT"); String schema = result.getString("PROCEDURE_SCHEM"); log("Reading procedure " + ((schema != null) && (schema.length() > 0) ? schema + "." : "") + procedureName, Project.MSG_INFO); xmlWriter.writeElementStart(null, "procedure"); xmlWriter.writeAttribute(null, "name", procedureName); if (catalog != null) { xmlWriter.writeAttribute(null, "catalog", catalog); } if (schema != null) { xmlWriter.writeAttribute(null, "schema", schema); } addStringAttribute(xmlWriter, "remarks", result, columns, "REMARKS"); if (columns.contains("PROCEDURE_TYPE")) { try { switch (result.getShort("PROCEDURE_TYPE")) { case DatabaseMetaData.procedureReturnsResult: xmlWriter.writeAttribute(null, "type", "returns result"); break; case DatabaseMetaData.procedureNoResult: xmlWriter.writeAttribute(null, "type", "doesn't return result"); break; case DatabaseMetaData.procedureResultUnknown: xmlWriter.writeAttribute(null, "type", "may return result"); break; default: xmlWriter.writeAttribute(null, "type", "unknown"); break; } } catch (SQLException ex) { log("Could not read the PROCEDURE_TYPE value for the procedure '" + procedureName + "' from the result set: " + ex.getStackTrace(), Project.MSG_ERR); } } dumpProcedure(xmlWriter, metaData, "%", "%", procedureName); xmlWriter.writeElementEnd(); } } public void handleError(SQLException ex) { log("Could not read the procedures from the result set: " + ex.getStackTrace(), Project.MSG_ERR); } }); }
From source file:org.seasar.dbflute.logic.jdbc.metadata.basic.DfProcedureExtractor.java
protected void setupProcedureMetaInfo(List<DfProcedureMeta> procedureMetaInfoList, ResultSet procedureRs, UnifiedSchema unifiedSchema) throws SQLException { while (procedureRs.next()) { // /- - - - - - - - - - - - - - - - - - - - - - - - // same policy as table process about JDBC handling // (see DfTableHandler.java) // - - - - - - - - - -/ final String procedureSchema = procedureRs.getString("PROCEDURE_SCHEM"); final String procedurePackage; final String procedureCatalog; final String procedureName; {// www . j a va 2s.c o m final String plainCatalog = procedureRs.getString("PROCEDURE_CAT"); if (isDatabaseOracle()) { // because Oracle treats catalog as package if (Srl.is_NotNull_and_NotTrimmedEmpty(plainCatalog)) { procedurePackage = plainCatalog; } else { procedurePackage = null; } procedureCatalog = null; } else { procedurePackage = null; if (Srl.is_NotNull_and_NotTrimmedEmpty(plainCatalog)) { procedureCatalog = plainCatalog; } else { procedureCatalog = unifiedSchema.getPureCatalog(); } } final String plainName = procedureRs.getString("PROCEDURE_NAME"); if (Srl.is_NotNull_and_NotTrimmedEmpty(procedurePackage)) { procedureName = procedurePackage + "." + plainName; } else { procedureName = plainName; } } final Integer procedureType = Integer.valueOf(procedureRs.getString("PROCEDURE_TYPE")); final String procedureComment = procedureRs.getString("REMARKS"); final DfProcedureMeta metaInfo = new DfProcedureMeta(); metaInfo.setProcedureCatalog(procedureCatalog); metaInfo.setProcedureSchema(createAsDynamicSchema(procedureCatalog, procedureSchema)); metaInfo.setProcedureName(procedureName); if (procedureType == DatabaseMetaData.procedureResultUnknown) { metaInfo.setProcedureType(DfProcedureType.procedureResultUnknown); } else if (procedureType == DatabaseMetaData.procedureNoResult) { metaInfo.setProcedureType(DfProcedureType.procedureNoResult); } else if (procedureType == DatabaseMetaData.procedureReturnsResult) { metaInfo.setProcedureType(DfProcedureType.procedureReturnsResult); } else { String msg = "Unknown procedureType: type=" + procedureType + " procedure=" + procedureName; throw new IllegalStateException(msg); } metaInfo.setProcedureComment(procedureComment); metaInfo.setProcedurePackage(procedurePackage); metaInfo.setProcedureFullQualifiedName(buildProcedureFullQualifiedName(metaInfo)); metaInfo.setProcedureSchemaQualifiedName(buildProcedureSchemaQualifiedName(metaInfo)); procedureMetaInfoList.add(metaInfo); } }