Jdbc Core Technology 3-stored procedure and jdbc Core Technology

Source: Internet
Author: User

Jdbc Core Technology 3-stored procedure and jdbc Core Technology
What is a stored procedure? A stored PROCEDURE is a piece of code stored IN a database. It can be called by a program to create a stored PROCEDURE create PROCEDURE SELECT_TESTTWO (in testid long, inout testall varchar (255 ))
BEGIN
SELECT 'name' from test where id = testid into testall;
END
Create a stored PROCEDURE command: create PROCEDURE PROCEDURE_Name (input, output parameters, can have multiple)
Struct BEGIN SQL END;
Call a stored procedure @ TestPublic Void Test_PROCEDURE()ThrowsException {Class.ForName("Com. mysql. jdbc. Driver"); Connection connection = DriverManager.GetConnection(Url, user, password); CallableStatement callableStatement = connection. prepareCall ("call SELECT_TESTTWO (?,?) "); // Call the Stored Procedure callableStatement. setLong (1, 1); callableStatement. registerOutParameter (2, Types.VARCHAR); CallableStatement. execute (); // execute the Stored Procedure // Assert. assertNotNull (callableStatement); System.Out. Println (callableStatement. getString (2 ));}
Show all stored procedures
Show procedure status; delete a stored PROCEDURE drop procedure demo;
Drop procedure SELECT_test;
Drop procedure SELECT_testone;
The storage process improves the efficiency. We can directly reduce the communication with the database and reduce the network burden.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.