因为是用c3po连接数据库,无框架,要写到的sql语句,包含动态变量,执行的是批量添加executeBatch

解决方案 »

  1.   

    还是不明。insert into + select 不行?
      

  2.   

    使用addBatch(sql语句);
    循环调用addBatch(sql语句);
    然后执行executeBatch()方法;
      

  3.   

    insert into  select * from tablse
      

  4.   

    insert into t_fms_og_dictionary (DIC_KEY,DIC_LANG,DIC_VALUE) 
    select ?,?,? from dual 
    union all 
    select ?,?,? from dual 
    union all 
    select ?,?,? from dual
    用以上方法一次插入三条数据
    在pstmt.executeBatch();提交批量数据
      

  5.   

    use master
    go
    if exists(select * from sys.databases where name = 'stuDB')
    drop database stuDB
    go
    create database stuDB
    GO
    USE stuDB
    GO
    if exists(select * from sys.objects where name='stuinfo')
    drop table stuinfo
    go
    create table stuinfo(
    id int identity not null,
    stuname varchar(10) not null,
    sex varchar(10) not null,
    cencet varchar(20) not null
    )
    go
    if exists(select * from sys.objects where name ='pk_id')
    alter table stuinfo
    drop constraint pk_id
    go
    alter table stuinfo
    add constraint pk_id primary key (id)
    declare @i int
     set @i = 1
      while @i <10000
      begin
       insert into stuinfo values('NAME'+convert(varchar(10),@i),'SEX'+convert(varchar(10),@i),'cencet'+convert(varchar(10),@i))
       set @i=@i+1
      end
    go
    select * from stuinfo