str.append("select * from aaa");
str.append("go");
str.append("create proc ****");如何让让这三句sql语句是这样的格式?
select * from aaa
go
create proc ****因为那个go 无论是在aaa后面还是在create之前在数据库执行都语法错误!!

解决方案 »

  1.   

    其实存在两个问题:
    1、换行,这个用 \n,比如:str.append("select * from aaa\n");
    2、多语句执行:我记得JDBC不支持批量脚本运行,应该每次execute只能执行一句完整SQL,所以你还是把它们分开来执行吧。
      

  2.   

    str.append("select * from aaa\r\n");
    str.append("go\r\n");
    str.append("create proc ****\r\n");这样 打印出来是以下格式
    select * from aaa
    go
    create proc ****但是,那jdbc不支持transact-SQL指令,你写一堆go没用jdbc貌似不支持批量执行不相同的语句,所以lz 老老实实的一条语句一条语句的执行吧