资源简介
JAVA连接数据库SQL Server 2008的连接桥
代码片段和文件信息
/*=====================================================================
File: executeStoredProcedure.java
Summary: This Microsoft SQL Server 2005 JDBC Driver sample application
demonstrates how to retrieve a large OUT parameter from
a stored procedure with adaptive buffering.
---------------------------------------------------------------------
This file is part of the Microsoft SQL Server JDBC Driver Code Samples.
Copyright (C) Microsoft Corporation. All rights reserved.
This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation. See these other
materials for detailed information regarding Microsoft code samples.
THIS CODE AND INFORMATION ARE PROVIDED “AS IS“ WITHOUT WARRANTY OF
ANY KIND EITHER EXPRESSED OR IMPLIED INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
=====================================================================*/
import java.sql.*;
import java.io.*;
import com.microsoft.sqlserver.jdbc.SQLServerCallableStatement;
public class executeStoredProcedure {
public static void main(String[] args) {
// Create a variable for the connection string.
String connectionUrl =
“jdbc:sqlserver://localhost:1433;“ +
“databaseName=AdventureWorks;integratedSecurity=true;“;
// Declare the JDBC objects.
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try {
// Establish the connection.
Class.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver“);
con = DriverManager.getConnection(connectionUrl);
// Create test data as an example.
StringBuffer buffer = new StringBuffer(4000);
for (int i = 0; i < 4000; i++)
buffer.append( (char) (‘A‘));
PreparedStatement pstmt = con.prepareStatement(
“UPDATE Production.Document “ +
“SET DocumentSummary = ? WHERE (DocumentID = 1)“);
pstmt.setString(1 buffer.toString());
pstmt.executeUpdate();
pstmt.close();
// Query test data by using a stored procedure.
CallableStatement cstmt =
con.prepareCall(“{call dbo.GetLargeDataValue(? ? ? ?)}“);
cstmt.setInt(1 1);
cstmt.registerOutParameter(2 java.sql.Types.INTEGER);
cstmt.registerOutParameter(3 java.sql.Types.CHAR);
cstmt.registerOutParameter(4 java.sql.Types.LONGVARCHAR);
SQLServerCallableStatement SQLcstmt = (SQLServerCallableStatement) cstmt;
// If you have not already set the responseBuffering=adaptive in the
// connection properties you can set the response buffering to adaptive
// on the statement level before executing the
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2011-10-20 16:50 sqljdbc_1.2\
目录 0 2011-10-20 16:51 sqljdbc_1.2\chs\
目录 0 2011-10-20 16:50 sqljdbc_1.2\chs\auth\
目录 0 2011-10-20 16:50 sqljdbc_1.2\chs\auth\IA64\
文件 203320 2007-12-13 22:25 sqljdbc_1.2\chs\auth\IA64\sqljdbc_auth.dll
目录 0 2011-10-20 16:51 sqljdbc_1.2\chs\auth\x64\
文件 103480 2007-12-13 22:25 sqljdbc_1.2\chs\auth\x64\sqljdbc_auth.dll
目录 0 2011-10-20 16:51 sqljdbc_1.2\chs\auth\x86\
文件 79928 2007-12-13 22:25 sqljdbc_1.2\chs\auth\x86\sqljdbc_auth.dll
目录 0 2011-10-20 16:51 sqljdbc_1.2\chs\help\
文件 552 2007-12-13 22:23 sqljdbc_1.2\chs\help\default.htm
目录 0 2011-10-20 16:51 sqljdbc_1.2\chs\help\html\
文件 7345 2007-12-13 22:24 sqljdbc_1.2\chs\help\html\0041f9e1-09b6-4487-b052-afd636c8e89a.htm
文件 11489 2007-12-13 22:24 sqljdbc_1.2\chs\help\html\00f9e25a-088e-4ac6-aa75-43eacace8f03.htm
文件 3274 2007-12-13 22:25 sqljdbc_1.2\chs\help\html\027edab7-9b5c-4f5f-9469-fe00cf7798b6.htm
文件 4034 2007-12-13 22:24 sqljdbc_1.2\chs\help\html\028b8d61-9557-4c9f-b732-29e87a962de8.htm
文件 3712 2007-12-13 22:23 sqljdbc_1.2\chs\help\html\030ad599-0431-4242-9428-e9ead7b75b1d.htm
文件 3939 2007-12-13 22:23 sqljdbc_1.2\chs\help\html\0330ca1d-5e24-4ce3-9d2a-b931f20a0fcf.htm
文件 2687 2007-12-13 22:23 sqljdbc_1.2\chs\help\html\03649d56-3319-4867-bef1-559dfd221b8b.htm
文件 21430 2007-12-13 22:25 sqljdbc_1.2\chs\help\html\04178645-915f-4569-8907-d45e299bbe7d.htm
文件 4156 2007-12-13 22:24 sqljdbc_1.2\chs\help\html\048fe245-157f-4fd8-be75-ce54b83e02b3.htm
文件 4640 2007-12-13 22:24 sqljdbc_1.2\chs\help\html\04d36a25-7f95-4675-9690-4462671b3d67.htm
文件 3541 2007-12-13 22:23 sqljdbc_1.2\chs\help\html\04ea83b2-db5e-4b46-b016-9e496363827e.htm
文件 3340 2007-12-13 22:23 sqljdbc_1.2\chs\help\html\04eebd6a-016f-4462-82f5-ab34b945eec4.htm
文件 6754 2007-12-13 22:24 sqljdbc_1.2\chs\help\html\050548ca-c708-4224-8014-8b7830a860dd.htm
文件 3792 2007-12-13 22:25 sqljdbc_1.2\chs\help\html\053549ee-2018-47ab-9538-789dac2b150a.htm
文件 3627 2007-12-13 22:23 sqljdbc_1.2\chs\help\html\05bdb61f-26e8-480f-a1c1-1e46a8ed4b70.htm
文件 8382 2007-12-13 22:24 sqljdbc_1.2\chs\help\html\0610d667-a16d-4201-a14b-0a40048911e1.htm
文件 3688 2007-12-13 22:23 sqljdbc_1.2\chs\help\html\06225a1a-a58d-4bff-b2ef-be303f051644.htm
文件 4346 2007-12-13 22:24 sqljdbc_1.2\chs\help\html\069c68ff-442d-4104-917f-3445a3ad264a.htm
文件 15562 2007-12-13 22:23 sqljdbc_1.2\chs\help\html\073f3b9e-8edd-4815-88ea-de0655d0325e.htm
............此处省略1014个文件信息
评论
共有 条评论