drop procedure if exists p_hello_world; create procedure p_hello_world(in v_id int) begin ) then select '> 0'; elseif (v_id ) then select '= 0'; else select '< 0'; end if; end; call p_hello_world();…
WHILE DO drop procedure if exists p_while_do; create procedure p_while_do() begin declare i int; ; do select concat('index : ', i); ; end while; end; call p_while_do(); FOR LOOP drop procedure if exists p_for_loop; create procedure p_for_loop() begin…
drop procedure if exists p_hello_world; create procedure p_hello_world() begin declare id integer; ); ) default ''; /* don't work */ /*declare cur_user cursor for select id from p_user where id is not null and name is not null order by id;*/ declare…
drop procedure if exists p_hello_world; create procedure p_hello_world() begin declare v_number int; ); ; set v_varchar = 'hello world'; -- for debug select v_number; select v_varchar; end; call p_hello_world(); drop procedure if exists p_hello_world…
drop procedure if exists p_hello_world; create procedure p_hello_world() begin select sysdate(); end; call p_hello_world(); drop procedure if exists p_hello_world; create procedure p_hello_world(in v_id int) begin select * from t_user t where t.id =…
java jdbc使用SSH隧道连接mysql数据库demo   本文链接:https://blog.csdn.net/earbao/article/details/50216999   package com.yws.echo_socket;           import com.jcraft.jsch.JSch;   import com.jcraft.jsch.Session;       import java.sql.*;       //http://my.oschina.net…
一.背景 由于项目需要,需要在Sbt+Scala项目中连接MySQL数据库.由于之前使用Maven+Java进行依赖管理偏多,在Sbt+Scala方面也在不断进行摸索,特此记录,作为小模块知识的积累. 二.系统环境 Scala.Sbt.IDE的版本分别如下 Scala版本 ==> 2.11.8 Sbt版本   ==> 0.13.8 Idea Intellij版本   ==> 2016.2.2 三.步骤 3.1 新建SBT项目 3.2 添加Student类和程序入口 项目结构如下图所示 其…
一.MySQL游标的概念 1.游标介绍 MySQL的游标(cursor)是一个重要的概念,通过查找资料与自己的理解,主要得出以下几点关于自己的理解. 有数据缓冲的思想:游标的设计是一种数据缓冲区的思想,用来存放SQL语句执行的结果. 先有数据基础:游标是在先从数据表中检索出数据之后才能继续灵活操作的技术. 类似于指针:游标类似于指向数据结构堆栈中的指针,用来pop出所指向的数据,并且只能每次取一个. 2.游标优缺点: (1)游标的优点: 因为游标是针对行操作的,所以对从数据库中select查询得…
sudo apt-get install python-mysqldb #!/usr/bin/env python #encoding=utf-8 import sys import MySQLdb reload(sys) sys.setdefaultencoding('utf-8') try: conn=MySQLdb.connect(host='localhost',user='root',passwd='root',db='mysql',port=3306,charset='utf8')…
-- 使用cursor的demo -- ==============================## -- 删除存储过程 DROP PROCEDURE USP_TestCursor; DELIMITER $$ -- 创建存储过程 CREATE PROCEDURE USP_TestCursor () BEGIN -- 需要定义接收游标数据的变量 DECLARE CurID INT; -- 遍历数据结束标志 DECLARE done INT DEFAULT FALSE; -- 游标 DECLAR…