Given a string, return a string length 1 from its front, unless front is false, in which case return a string length 1 from its back. The string will be non-empty.
theEnd("Hello", true) → "H"
theEnd("Hello", false) → "o" theEnd("oh", true) → "o" public String theEnd(String str, boolean front) { char cf = str.charAt(0); char ct = str.charAt(str.length()-1); String strcf = String.valueOf(cf); String strct = String.valueOf(ct); if (front!=false){ return strcf; }return strct; } |
Stored Procedures: group of SQL statements that perform a particular task Normally created by DBA Can have any combination of input, output, and input/output parameters Benefits: Performance - compiled once but executable more times Productivity and Ease of Use - avoid redundant code, extend SQL Database functionality Scalability Maintainability Interoperability Replication Security To call stored procedure from Java The JDBC API provides the CallableStatement CallableStatement myCall = myConn.prepareCall("{ call some_stored_procedure() }"); ... myCall.execute(); JDBC API parameter types IN default INOUT OUT Stored Procedure can return result sets EXAMPLE: Created stored procedure on MySQL side - NAME: increase_salaries_for_department DELIMITER $$ DROP PROCEDURE IF EXISTS ` increase_salaries_for_department `$$ CREATE DEFINER=`student`@`localhost` PROCEDURE `increase_salaries_for_departme...
Komentarze
Prześlij komentarz