简体   繁体   English

从Netbeans连接到SQL Server

[英]connecting to SQL Server from Netbeans

I am trying to connect to a server instance of SQL Server 2010 that I installed recently using NetBeans. 我试图连接到最近使用NetBeans安装的SQL Server 2010服务器实例。 I have downloaded the latest JDBC driver for MS SQL Server, but I cannot get the right connection string to connect to this database. 我已经下载了用于MS SQL Server的最新JDBC驱动程序,但是无法获得正确的连接字符串来连接到该数据库。 I think I am missing the following values in the connection: 我认为我在连接中缺少以下值:

  • Port 港口
  • Instance Name 实例名称
  • and I am not sure if my username should be 而且我不确定我的用户名是否应该是 / *** or only the name that appears after the / / ***或仅显示在/之后的名称

'jdbc:sqlserver://' 'JDBC:SQLSERVER://'

Any help appreciated, 任何帮助,赞赏,

Ted 摊晒

Port number should normally be 1433 for MSSQL, but often, this may not even be specified, so to do that you would need to: 对于MSSQL, 端口号通常应为1433,但通常甚至可能没有指定端口号,因此您需要:

  1. Open Microsoft SQL Configuration Manager 打开Microsoft SQL配置管理器
  2. Find 'SQL Server Network Configuration' on the left pane and expand it 在左窗格中找到“ SQL Server网络配置”并将其展开
  3. Select 'Protocols for 选择“协议”
  4. Right-click TPC/IP on the right and select properties 右键单击右侧的TPC / IP并选择属性
  5. Make sure Enabled and Listen All have Yes chosen in the Protocol tab 确保在“协议”选项卡中选择“已启用”和“全部侦听”
  6. Select the IP Addresses tab and scroll to the end where IPAll is. 选择IP地址选项卡,然后滚动到IPAll所在的末尾。
  7. Type in 1433 in TCP Dynamic Ports and leave TCP Port empty 在“ TCP动态端口”中键入1433,并将“ TCP端口”保留为空
  8. Click OK then select SQL Server Services on the left pane 单击“确定”,然后在左窗格中选择“ SQL Server服务”
  9. Right-click on 'SQL Server (YOU SERVER NAME)' and click Restart 右键单击“ SQL Server(您的服务器名称)”,然后单击“重新启动”。

The instance name is not necessary, it can be left blank. 实例名称不是必需的,可以保留为空白。

Now for Username : 现在输入用户名

Note that what comes after // (jdbc:sqlserver://) is usually the host and not your username. 请注意,//(jdbc:sqlserver://)之后通常是主机,而不是您的用户名。

  1. Open Microsoft SQL Server Management Studio 打开Microsoft SQL Server Management Studio
  2. Right-click on the server and click properties 右键单击服务器,然后单击属性
  3. Go to Security and choose 'SQL Server and Windows Authentication mode' 转到“安全性”,然后选择“ SQL Server和Windows身份验证模式”
  4. You will get a warning asking you to restart your server. 您将收到警告,要求您重新启动服务器。 Ignore this for now and go back into Microsoft SQL Server Management Studio 暂时忽略此内容,然后返回到Microsoft SQL Server Management Studio
  5. Expand 'Security' then expand 'Logins' 展开“安全性”,然后展开“登录”
  6. You will find the default user called 'sa', right-click on it and select Properties 您将找到默认用户“ sa”,右键单击它并选择“属性”。
  7. In General you can enter a password of your choice, enter the same password in Confirm Password 通常,您可以输入所需的密码,然后在“确认密码”中输入相同的密码。
  8. Click 'Status' on the left and make sure Login is 'Enabled' then OK everything! 单击左侧的“状态”,并确保“登录”为“启用”,然后确定一切!

Go back into NetBeans and try to connect again. 返回NetBeans,然后尝试再次连接。 This time using Port 1433, nothing for Instance Name, username as 'sa' and password . 这次使用端口1433,实例名称,用户名'sa'和密码都没有。 Test the connection to ensure you get no errors. 测试连接以确保没有错误。 Good luck. 祝好运。

This should help: 这应该有助于:

http://netbeans.org/kb/docs/java/gui-db.html http://netbeans.org/kb/docs/java/gui-db.html

Edit : As per comment below this was for derby stuff. 编辑 :根据下面的评论这是德比的东西。 Here is a more useful link but it's not got any information on supplying the DB username or password. 这是一个更有用的链接,但没有提供数据库用户名或密码的任何信息。 It might be enough depending on your exact requirement. 根据您的确切要求,可能就足够了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM