首先通过pl/sql建立一个存储过程Xiao_Note
create or replace procedure Xiao_Note
(
name in varchar2,
email in varchar2,
dept in varchar2
)
is
begin
insert into email (id,name,email,dept) values(Autoaddid.Nextval,name,email,dept);
commit;
end Xiao_Note;
其中
Autoaddid.Nextval是建的一个oracle的自增长序列,用于做主键用的
编译成功后。测试
。。。
public static void main(String[] args) throws SQLException {
CommonDAO dao=new CommonDAO();
Connection conn=dao.getConnection();
String procedure = "{call XIAO_NOTE(?,?,?)}";
CallableStatement cstmt = conn.prepareCall(procedure);
cstmt.setString(1,"liuyong1111");
cstmt.setString(2,"liuyongcic@163.com");
cstmt.setString(3,"xx");
cstmt.executeUpdate();
System.out.println("ok");
}
。。。