SQLSERVER扩展存储过程XP_CMDSHELL的简单应用
2007-11-11 11:06:16 来源:WEB开发网
先在sql server(WINDOWS平台上强大的数据库平台)中创建存储过程如下:
CREATE PROCEDURE InsertOrtho
(@ChildID varchar(10) out,
@date datetime out,
@therapistID varchar(10) out,
@clinicID integer out,
@skeletal varchar(1) out,
@angleClass varchar(1) out,
@deflection varchar(1) out,
@OrthoNotes varchar(200) out)
AS
BEGIN
INSERT INTO tblPatientOrtho VALUES
(@ChildID, @date, @TherapistID, @ClinicID, @Skeletal, @angleClass, @deflection, @OrthoNotes)
RETURN
END
这是一个向数据库插入的存储过程,所有的参数都是输出的,在JAVA里可以这样调用这个存储过程,程序如下:
前面数据库的连接我就不写了
public boolean InsertOrtho(Ortho ortho, String childID)
{
boolean success = true;
try
{
CallableStatement stmt = con.prepareCall("{call InsertOrtho(?, ?, ?, ?, ?, ?, ?, ?)}");
stmt.registerOutParameter(1, java.sql.Types.VARCHAR);
stmt.registerOutParameter(2, java.sql.Types.TIMESTAMP);
stmt.registerOutParameter(3, java.sql.Types.VARCHAR);
stmt.registerOutParameter(4, java.sql.Types.INTEGER);
stmt.registerOutParameter(5, java.sql.Types.VARCHAR);
stmt.registerOutParameter(6, java.sql.Types.VARCHAR);
stmt.registerOutParameter(7, java.sql.Types.VARCHAR);
stmt.registerOutParameter(8, java.sql.Types.VARCHAR);
stmt.setString(1, childID);
stmt.setObject(2, ortho.GetDate());
stmt.setString(3, ortho.GetTherapistID());
stmt.setInt(4, ortho.GetClinicID());
stmt.setString(5, ortho.GetSkeletal());
stmt.setString(6, ortho.GetAngleClass());
stmt.setString(7, ortho.GetDeflection());
stmt.setString(8, ortho.GetOrthoNotes());
stmt.executeUpdate();
stmt.clearParameters();
stmt.close();
}
catch (SQLException e)
{
database.AddSQLError(e, "InsertOrtho()");
e.printStackTrace();
success = false;
}
catch (java.lang.Exception e)
{
database.AddException(e, "InsertOrtho()");
e.printStackTrace();
success = false;
}
return success;
}
希望对大家的数据库开发有所帮助
- ››sqlserver安装和简单的使用
- ››SqlServer触发器、存储过程和函数
- ››SQLServer建立交叉表查询
- ››SqlServer强制断开数据库连接的方法
- ››SQLServer 2005 海量数据解决方案
- ››SQLServer 2008数据库查看死锁、堵塞的SQL语句
- ››SqlServer 插入多条数据
- ››SQLServer 2008 R2导出的SQL文件中没有数据
- ››SQLSERVER通过游标查询两个数据表共有字段名组合成...
- ››sqlserver2008实现拼音首字母和随机n位数的生成
- ››SQLServer与Java数据类型对应表
- ››sqlserver的日常检查脚本归结
更多精彩
赞助商链接