测试freetds是否能连mssql

测试freetds是否能连mssql,第1张

freetds连接失败可能原因:

1. mssql服务器是否开放远程连接

2.防火墙是否限制了连接

3. 端口号是否正确,默认是1433

4.配置文件中servername中是否指定tdsrve verstion

Start with ping

First ping the host to make sure you can talk to the machine the server resides on.

Example 8-1. Finding the server's host

$ ping -c1 myhost

PING myhost (127.0.0.1) from 127.0.0.1 : 56(84) bytes of data.

64 bytes from myhost (127.0.0.1): icmp_seq=0 ttl=255 time=250 usec

A successful ping shows that your network isn't preventing you from reaching the machine hosting the server.

Test with telnet

Attempt to telnet to the port, to verify that the dataserver is listening.

Example 8-2. Finding the server

$ telnet myhost 1433

Trying 127.0.0.1...

Connected to myhost.

Escape character is '^]'.

If you get output as above, the dataserver is listening. If you get a'Connection Refused' message, you're talking to the wrong host, wrongport, or the dataserver is down. [1]

Test with tsql

tsql can be run in two ways, one which uses freetds.conf and one which connects directly using the host and port. First attempt a connection using host and port.

Example 8-3. Connecting to the server, bypassing freetds.conf

$ cd src/apps

$ TDSVER=7.0 ./tsql -H myhost -p 1433 -U user

If you receive a message of 'Login Failed.' then your connectivity is OK, but you have a authentication issue.

If you receive a message like

Msg. No.: 18450 Severity: 14 State: 1 Login failed- User: loginid Reason: Not defined as a valid user of a trusted SQL Server connection

SQL Server is accepting only "domain" logins. This applies only to Microsoft SQL Server and you'll need to have your DBA verify that "server logins"are allowed, or use a domain login.

Finally, if you received a prompt, then try tsql using the dataserver name.

Example 8-4. Connecting to the server using freetds.conf

$ ./tsql -S myserver -U user

If this fails, FreeTDS is either not finding your freetds.conf file, finding the wrong one, or there is an error in the file.

Notes

[1]

To exit telnet: When connected, telnet's command mode may be entered by typing the telnet escape character (initially Ctrl-], as above). Once in command mode, telnet may be exited with the command quit.

1、要连接数据库首先需要配置连接串,配置上服务器数据库等信息//connString = "Data Source=服务器名称Initial Catalog=数据库名称User ID = 用户名Pwd = 密码"。

2、之后需要打开数据库连接 conn.ConnectionString = connStringconn.Open()// 打开数据库连接。

3、写好查询sql后实例化适配器。

4、 实例化数据表,把数据表储存到DataTable中。

5、插入sql和执行sql方式不同,插入sql必须存在sqlc.ExecuteNonQuery()。

6、在操作完成后需要关闭数据库连接。

1、双击桌面pl/sql developer软件图标启动软件。

2、在登录窗口中填写登录信息,并选择登录角色。

3、登录成功后点击右上角新建按钮,选择用户功能。

4、在新建用户窗口中,默认常规选项中可以填写用户的基本信息及密码。

5、在三个权限窗口中可为用户配置不同的权限。

6、另外点击右下角查看sql功能中也可以在sql窗口中直接进行创建用户即可完成。


欢迎分享,转载请注明来源:夏雨云

原文地址:https://www.xiayuyun.com/zonghe/149247.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-03-20
下一篇2023-03-20

发表评论

登录后才能评论

评论列表(0条)

    保存