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:
- Open Microsoft SQL Configuration Manager
- Find 'SQL Server Network Configuration' on the left pane and expand it
- Select 'Protocols for
- Right-click TPC/IP on the right and select properties
- Make sure Enabled and Listen All have Yes chosen in the Protocol tab
- Select the IP Addresses tab and scroll to the end where IPAll is.
- Type in 1433 in TCP Dynamic Ports and leave TCP Port empty
- Click OK then select SQL Server Services on the left pane
- 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.
- Open Microsoft SQL Server Management Studio
- Right-click on the server and click properties
- Go to Security and choose 'SQL Server and Windows Authentication mode'
- You will get a warning asking you to restart your server. Ignore this for now and go back into Microsoft SQL Server Management Studio
- Expand 'Security' then expand 'Logins'
- You will find the default user called 'sa', right-click on it and select Properties
- In General you can enter a password of your choice, enter the same password in Confirm Password
- 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.
精彩评论