java sql连接

发布于 2024-09-24 23:42:05 字数 378 浏览 2 评论 0原文

我创建了一个名为“harshi”的用户 dsn
要在从 Java 代码获取数据的表中插入行,我想插入 SQL 表中。 连接语句是:

String url = "jdbc:odbc:Harshi"; 
Connection conn = DriverManager.getConnection(url,"",""); 
Statement st = conn.createStatement(); 

我仍然得到输出:

出现异常!
[微软][ODBC SQL Server 驱动程序][共享内存]SQL Server 确实 不存在或访问被拒绝。

我该如何解决?

I have created a user dsn named "harshi"
To insert rows in a table getting data from Java code I want to insert in SQL table.
The connection statement is:

String url = "jdbc:odbc:Harshi"; 
Connection conn = DriverManager.getConnection(url,"",""); 
Statement st = conn.createStatement(); 

Still I am getting output as:

Got an exception!
[Microsoft][ODBC SQL Server
Driver][Shared Memory]SQL Server does
not exist or access denied.

How can I solve it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回首观望 2024-10-01 23:42:05

要解决此错误,请尝试以下方法之一:

  • DSN 是否包含正确的凭据?
  • 如果使用 SQL Server 身份验证,请尝试通过 SQL Server Management Studio 使用这些确切的凭据登录。
  • 如果使用 Windows 身份验证,发出请求的帐户是否有权访问 SQL Server?
  • 应用程序机器和数据库机器之间是否有防火墙?
  • 自创建 DSN 以来,目标计算机的 IP 地址是否已更改?
  • 尝试删除&重新创建 DSN。

To troubleshoot this error, try one of these:

  • does the DSN contain good credentials?
  • If using SQL Server Authentication, try logging in using those exact credentials via SQL Server Management Studio
  • If using Windows Authentication, does the account making the request have permissions to the SQL Server?
  • Are there any firewalls in between the application machine and the database machine?
  • Has the IP address of the destination machine changed since the DSN was created?
  • Try deleting & recreating the DSN.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文