存储过程getUserRole:
CREATE PROC dbo.getUserRole
AS
create table tempt(userName varchar(20),userXM varchar(20),roleName varchar(8000))
insert into tempt
select b.userName,b.userXM,a.roleName from scopeManage_role a,scopeManage_user b
where charindex(','+rtrim(a.roleId)+',',','+b.roleId+',')>0
select * from tempt
drop table tempt
GO
JAVA调试文件:
import java.sql.*;
import java.util.*;
import com.data.DataControl;
public class UtilUser {
private static CallableStatement callsta;
public static void getAll() {
DataControl db = new DataControl();
try {
callsta=db.getCon().prepareCall("{call getUserRole}");
System.out.print(callsta.execute());
ResultSet re=callsta.getResultSet();
while(re.next())
{
System.out.println(re.getString("userName"));
}
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}
经测,System.out.print(callsta.execute())输出为false,但是在SQL2000中发现tempt表的确被创建了,请问这是怎么回事?
CREATE PROC dbo.getUserRole
AS
create table tempt(userName varchar(20),userXM varchar(20),roleName varchar(8000))
insert into tempt
select b.userName,b.userXM,a.roleName from scopeManage_role a,scopeManage_user b
where charindex(','+rtrim(a.roleId)+',',','+b.roleId+',')>0
select * from tempt
drop table tempt
GO
JAVA调试文件:
import java.sql.*;
import java.util.*;
import com.data.DataControl;
public class UtilUser {
private static CallableStatement callsta;
public static void getAll() {
DataControl db = new DataControl();
try {
callsta=db.getCon().prepareCall("{call getUserRole}");
System.out.print(callsta.execute());
ResultSet re=callsta.getResultSet();
while(re.next())
{
System.out.println(re.getString("userName"));
}
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}
经测,System.out.print(callsta.execute())输出为false,但是在SQL2000中发现tempt表的确被创建了,请问这是怎么回事?
callsta=db.getCon().prepareCall("{call getUserRole}");
ResultSet re=callsta.executeQuery();然后确定你的存储过程执行的没问题,在查询分析器中执行你的存储过程看看有没有问题。
sm.execute("exec getUserRole ");