开发者

connecting to SQL Server from Netbeans

I am trying to connect to a server instance of SQL Server 2010 that I ins开发者_StackOverflow中文版talled recently using NetBeans. I have downloaded the latest JDBC driver for MS SQL Server, but I cannot get the right connection string to connect to this database. 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://'

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:

  1. Open Microsoft SQL Configuration Manager
  2. Find 'SQL Server Network Configuration' on the left pane and expand it
  3. Select 'Protocols for
  4. Right-click TPC/IP on the right and select properties
  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.
  7. Type in 1433 in TCP Dynamic Ports and leave TCP Port empty
  8. Click OK then select SQL Server Services on the left pane
  9. Right-click on 'SQL Server (YOU SERVER NAME)' and click Restart

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.

  1. Open 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'
  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
  5. Expand 'Security' then expand 'Logins'
  6. You will find the default user called 'sa', right-click on it and select Properties
  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. This time using Port 1433, nothing for Instance Name, username as 'sa' and password . Test the connection to ensure you get no errors. Good luck.


This should help:

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜