网页资讯视频图片知道文库贴吧地图采购
进入贴吧全吧搜索

 
 
 
日一二三四五六
       
       
       
       
       
       

签到排名:今日本吧第个签到,

本吧因你更精彩,明天继续来努力!

本吧签到人数:0

一键签到
成为超级会员,使用一键签到
一键签到
本月漏签0次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行补签。
连续签到:天  累计签到:天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
02月04日漏签0天
sql吧 关注:57,240贴子:144,916
  • 看贴

  • 图片

  • 吧主推荐

  • 游戏

  • 2回复贴,共1页
<<返回sql吧
>0< 加载中...

连接 SQL Server

  • 只看楼主
  • 收藏

  • 回复
  • neureddream
  • 中级粉丝
    2
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
SQL Server  

JDBC 
jTDS 
Class.forName("net.sourceforge.jtds.jdbc.Driver ");
Connection con = DriverManager.getConnection("jdbc:jtds:sqlserver://host:port/database","user","password");  
点击此处下载jtds jdbc驱动  
SQL Server 2000 Driver for JDBC 
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection conn = DriverManager.getConnection ("jdbc:microsoft:sqlserver://server1:1433","user","password");  
点击此处下载microsoft sqlserver jdbc驱动  

ODBC 
Standard Security 
Driver={SQL Server};Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword; 
 
Trusted connection 
Driver={SQL Server};Server=myServerAddress;Database=myDataBase;Trusted_Connection=Yes; 
 
Prompt for username and password 
oConn.Properties("Prompt") = adPromptAlways 

Driver={SQL Server};Server=myServerAddress;Database=myDataBase; 
(注意:这个连接串需要在连接前设定Prompt属性,然后才能连接 ) 
原文解释:This one is a bit tricky. First you need to set the connection object's Prompt property to adPromptAlways. Then use the connection string to connect to the database.  

OLE DB, OleDbConnection (.NET) 
Standard Security 
Provider=sqloledb;Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword; 
 
Trusted connection 
Provider=sqloledb;Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI; 
(注意:数据源使用服务器名/实例名 只能在sql server2000版本中,早先的版本是不用的 ) 
原文解释:Use serverName\instanceName as Data Source to use a specific SQL Server instance. Please note that the multiple SQL Server instances feature is available only from SQL Server version 2000 and not in any previous versions.  
Prompt for username and password 
oConn.Provider = "sqloledb"
oConn.Properties("Prompt") = adPromptAlways

Data Source=myServerAddress;Initial Catalog=myDataBase; 
(注意:连接前先要设置Provider 和 prompt ) 
原文解释:This one is a bit tricky. First set the connection object's Provider property to "sqloledb". Thereafter set the connection object's Prompt property to adPromptAlways. Then use the connection string to connect to the database.  
Connect via an IP address 
Provider=sqloledb;Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword; 
(DBMSSOCN=TCP/IP , 使用tcp/ip代替命名通道。默认端口为1433) 
原文解释:DBMSSOCN=TCP/IP. This is how to use TCP/IP instead of Named Pipes. At the end of the Data Source is the port to use. 1433 is the default port for SQL Server.  

SqlConnection (.NET) 
Standard Security 
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword; 
 
Standard Security alternative syntax 
Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False; 
(注意:这个连接串和上面那个是一样的,因为他们的参数是等价的 ) 
原文解释:This connection string produce the same result as the previous one. The reason to include it is to point out that some connection string keywords have many equivalents.  
Trusted Connection 
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI; 
 
Trusted Connection alternative syntax 
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True; 
(注意:这个连接串和上面那个是一样的,因为他们的参数是等价的 ) 
原文解释:This connection string produce the same result as the previous one. The reason to include it is to point out that some connection string keywords have many equivalents.  
Connect via an IP address 
Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword; 
 
Specifying packet size 
Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False; Packet Size=4096; 
(注意:.net默认设置Packet Size为8192.最佳的设置最好为4096 ) 
原文解释:By default, the Microsoft .NET Framework Data Provider for SQL Server sets the network packet size to 8192 bytes. This might however not be optimal, try to set this value to 4096 instead.  

Data Shape 
MS Data Shape 
Provider=MSDataShape;Data Provider=SQLOLEDB;Data Source=myServerAddress;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword; 



  • 218.104.96.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
保存


2026-02-04 11:38:31
广告
不感兴趣
开通SVIP免广告
  • 218.104.96.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
这是啥?


登录百度账号

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!
  • 贴吧页面意见反馈
  • 违规贴吧举报反馈通道
  • 贴吧违规信息处理公示
  • 2回复贴,共1页
<<返回sql吧
分享到:
©2026 Baidu贴吧协议|隐私政策|吧主制度|意见反馈|网络谣言警示