public String executeProc(String s)
{
rs = null;
String s2 = "{call PROC_AUTOID(?,?)}";
String s1;
try
{
if(conn != null)
conn.close();
conn = DriverManager.getConnection(sConnStr, UseName, PassWord);
CallableStatement callablestatement = conn.prepareCall(s2);
callablestatement.setString(1, s);
callablestatement.registerOutParameter(2, 1);
rs = callablestatement.executeQuery();
rs.next();
String s3 = rs.getString(1);
s1 = callablestatement.getString(2);
rs.close();
callablestatement.close();
conn.close();
conn = null;
}
catch(Exception exception)
{
return null;
}
return s1.trim();
}
{
rs = null;
String s2 = "{call PROC_AUTOID(?,?)}";
String s1;
try
{
if(conn != null)
conn.close();
conn = DriverManager.getConnection(sConnStr, UseName, PassWord);
CallableStatement callablestatement = conn.prepareCall(s2);
callablestatement.setString(1, s);
callablestatement.registerOutParameter(2, 1);
rs = callablestatement.executeQuery();
rs.next();
String s3 = rs.getString(1);
s1 = callablestatement.getString(2);
rs.close();
callablestatement.close();
conn.close();
conn = null;
}
catch(Exception exception)
{
return null;
}
return s1.trim();
}
解决方案 »
- 如何实现带条件的分页?
- 麻烦问问达人们做一个旅游管理软件需要多钱预算
- 高分求原码!!!!
- 有trim()网页出错
- 100分啊,在jbuilder中建立javabean后用beaninsight检查系统老是说找不到类?哭泣中...
- 如何检测查询数据库是否获得结果呢?是使用ResultSet.getRow()这个方法么?多谢!
- 如何让表单里的下拉菜单设成我指定的宽度?如何调整多文本编辑域的宽度,和高度?如何使超连接文字没有下划线?
- javascript字符串的问题!!!分数不够另加!!!网上等!!!解决就给分!!
- 这段代码错在哪里啊
- Struts2关于struts.xml的配置问题,我又404了,新人求大神指教,感激不尽!
- 大家快来看啊,这个程序哪有问题,编译时,不可以通过!
- 谁有jspsmartupload组件
SQL Server: call 存储过程名(参数1,参数2,...)3.unknown
4.既然有可以用的,那就用可以用的吧
a是用来执行查询的,这个方法将返回ResultSet.(自己看看Statement类就会明白了)
kongxiangli(笑看红尘)
yaray(雅睿,生活在别处) 另外, kongxiangli(笑看红尘) 说是:"{call PROC_AUTOID(?,?)}";但我用的是这样的:"{call PROC_AUTOID(?)}";
如果有两个参数:"{call PROC_AUTOID(??)}";
如果有三个参数:"{call PROC_AUTOID(???)}";
我试过,是成功的
不知道有什么区别,
{call PROC_AUTOID(?,?)};是标准写法
存储过程名:add_user
参数: @uname nvarchar(10) , @nums int(4) output
如何得到参数@nums的值呢,我用ASP能写,但JSP用什么语法都不知道,很郁闷啊
conn = DriverManager.getConnection(sConnStr, UseName, PassWord);
CallableStatement callablestatement = conn.prepareCall(s2);
callablestatement.setString(1, s);
callablestatement.registerOutParameter(2, Types.VARCHAR);
callablestatement.execute();
s1 = callablestatement.getString(2); //获得输出参数的值啊!!
想把哪个作为输出参数就用下面的方法,在()中指明是第几个参数和该参数的类型
callablestatement.registerOutParameter(2, Types.VARCHAR); 是第一种理解对还是第二种理解对?
callablestatement.registerOutParameter(2, Types.VARCHAR);
是输入还是输出由这两句话决定的,你希望是输入就用set否则用out