日期:2014-05-16  浏览次数:20480 次

jdbc笔记心得
CallableStatement:     存储过程
建立一个存储过程
create table sun_student(
id number(4) primary key,
name varchar2(20),
age      number(20),
sex       char
);
/****************************************************************
create or replace procedure insert_sun(
v_id  number,
v_name varchar2,
v_age number,
v_sex char
)
is
begin
insert into sun_student (id,name,age,sex)
values (v_id,v_name,v_age,v_sex);
commit;
end;
执行
exec insert_sun(1,'perter',20,'M');
/****************************************************************
create or replace procedure insert_sun1(
v_deptno  emp.deptno%type,
v_count out  number
)
is
begin
select count(*) into v_count
from emp where deptno=v_deptno;
commit;
end;

匿名块
set serveroutput on //打开sqlplus的开关
declare
v_count  number;
begin
insert_sun1(20,v_count);
dbms_output.put_line(v_count);
end;
/
/***************************************************************************
二,sql语句的批处理   ((批量处理)
B:business
C:customer
B2B: 阿里巴巴
B2C: 360buy.com ,当当,卓越,凡客
C2C: taobao
autoexec.bat
String sql1=".........";
String sql2=".........";
//conn.autoCommit(false);
//stmt.addBatch();
//stmt.executeBatch();
//conn.commit();
优化操作
create table mytemp(
id number primary key,
name varchar2(50)
)
增加到批处理缓存中的语句,可以隔一段
就执行,这样提高效率

--mysql
create table student(
id number primary key auto_incremnet,
name varchar2(20)
);
insert into student(name) values('petpr');
select * from student;
-----------------------------------------
序列实现自动增长的功能
create sequence myseq
start with 1000 increment by 10;
insert into mystu(id ,name,age,sex)
values (myseq.nextval,'chris',20,'M');

四.连接池
                     open                sql
connection  <->statement  <->resultset
                     close

tomcat:apache
weblogic : bea(oracle)

websphere: ibm
Oracle <---------------> Google
(sun) 开源机构 android
jdk harmony java

jdk+tomcat+mysql