javaÖÐÈçºÎÒÔwindows¼¯³É·½Ê½Á¬½ÓSQL Server
ÔÚ¡¶JDBC Driver For SQL2000/2005/2008
¡·Ò»ÎÄÖУ¬ÑûÔ½éÉÜÁËÈçºÎÏÂÔز¢Ê¹ÓÃjdbcÁ¬½ÓSQL Server,
½ñÌìÓÐÈËÎÊÆð£¬ÈçºÎÒÔwindows¼¯³É·½Ê½Á¬½ÓSQL Server,Õâ¸öÒÔÇ°ÕæûÊÔ¹ý¡£
ÓÚÊÇ£¬´ò¿ªnetBeans²âÊÔÁËһϣ¬´úÂëÈçÏ£º
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package testsqlconn;
import java.sql.*;
import com.microsoft.sqlserver.jdbc.*;
/** *//**
*
* @author: Administrator:downmoon(3w@live.cn)
* @date:2009-9-23 18:42:32
* @Encoding:UTF-8
* @File:TestSqlbyDS/TestSqlbyDS.java
* @Package:testsqlconn
*/
public class TestSqlbyDS {
public TestSqlbyDS(){}
public void GetResutls()
{
// Declare the JDBC objects.
Connection con = null;
CallableStatement cstmt = null;
ResultSet rs = null;
try {
// Establish the connection.
SQLServerDataSource ds = new SQLServerDataSource();
ds.setIntegratedSecurity(true);
ds.setServerName("ap4\\agronet08");//Êý¾Ý¿âʵÀýÃû
ds.setPortNumber(1433);
ds.setDatabaseName("AdventureWorksLT2008");//Database Name
con = ds.getConnection();
// Execute a SQL that returns some data.
//cstmt = con.prepareCall("{call dbo.uspGetEmployeeManagers(?)}");
//cstmt.setInt(1,50);
cstmt = con.prepareCall(" select top 10 * from [SalesLT].[Product] ");//Sql
rs = cstmt.executeQuery();
// Iterate through the data in the result set and display it.
while (rs.next()) {
System.out.println("Product: " + rs.getString("Name") + ", " + rs.getString("ProductNumber"));
System.out.println("ListPrice: " + rs.getString("ListPrice"));
System.out.println();
}
} // Handle any errors that may have occurred.
ca
Ïà¹ØÎĵµ£º
BUILTIN\Administrators
-- Õâ¸öÊÇAdmin×éµÄȨÏÞ,ĬÈÏÇé¿öϱ¾µØAdmin¶¼Á¥ÊôÓÚÕâ¸ö×é,¾ßÓбȽϴóµÄȨÏÞ,
-- ×÷ΪWindows¼¯³ÉµÇ¼,Èç¹ûʹÓõÄÊǹÜÀíÔ±,¾Í»áʹÓõ½Ëü,
HC811\ASPNET
-- Õâ¸öÊÇASPNETÓ¦ÓõķÃÎÊÕʺÅ×é,
HC811\SQLServer2005MSFTEUser$HC811$MSSQLSERVER
-- Õâ¸öÊÇÈ«ÎÄË÷ÒýµÄ·ÃÎÊÕʺ ......
µÚÒ»ÖÖ·½·¨: ʹÓÃoutput²ÎÊý
USE AdventureWorks;
GO
IF OBJECT_ID ( 'Production.usp_GetList', 'P' ) IS NOT NULL
DROP PROCEDURE Production.usp_GetList;
GO
CREATE PROCEDURE Production.usp_GetList @product varchar(40)
, @maxprice money
, ......
1¡¢Ñ»·²åÈë²âÊÔÊý¾Ý£º
SQL>
declare
maxrecords constant int:=100;
i int :=1;
Begin
for i in 1..maxrecords loop
--²åÈëÊý¾Ý
Insert into TEST.EXAMPLE(name,phone,address) values('·ÖÒ³²âÊÔÊý¾Ý....','ÁªÏµµç»°','ÁªÏµµØÖ·');
end loop;
commit;
end;
´Ë´¦EXAMPLE±í¶¨ÒåΪ(ID number,name ......
HR·þÎñÆ÷£º ²Ù×÷ϵͳ->32λWindows2000 SP4 Êý¾Ý¿â->32λSQL Server2000
OA·þÎñÆ÷£º ²Ù×÷ϵͳ->64λWindows2003 SP2 Êý¾Ý¿â->64λSQL Server2005
OAÏî ......