Finding Connection Information for MS SQL Server - sql-server

So I just downloaded Microsoft SQL Server 2019 (Developer) and the Server Management Software as well. I am trying to connect one of this new server's databases to an IntelliJ IDE Project, but I don't know where to find the connection information from.
Here is the IntelliJ DB connection page with the information
This is the information I need. I'm a CS student and took a 4000 level class before taking Design of Database systems. I'm sure I can make it work once I get the connection working, its just JSF and JDBC and SQLJ project.

So for anyone connecting a SQL Server for the first time to IntelliJ using Microsoft SQL Server Management and Microsoft SQL Server I will leave this:
Go to Windows search type Services
Navigate down to SQL Server Browser, right click Properties
Change startup type to automatic, under Service Status click Run
Go to MSSM, under Security enable Windows authentication and Server authentication
Go to SQL Server Configuration program from search
Make sure Server Browser is running, go to SQL Server Network Configuration (not 32-bit)
Click the arrow, go to Protocols for SQLEXPRESS (You may have a different name of SQLxxx if you downloaded another version than EXPRESS)
Enable TCP/IP by right-clicking enable
Right click and select properties
Under general, make sure Enabled is set to Yes, then go to Ip addresses. Scroll all the way down to IPAll
Set Dynamic Ports to blank, and TCP port to 1433. Restart your server.
In MSSM, under Security, create or change a login. SA is system admin, change the password if you want, or create another user by right clicking logins and adding if you want.
If you use sa, (I called it SA earlier I mean the same thing) make sure you right click go to properties status and make sure login is enabled. You can close out, and restart program, use Windows or Server authentication, if you want to use sa choose server authentication, then enter sa for user and whatever pass you made.
Now in intellij click the database pane. Choose a Microsoft SQL server, and the url by default is jdbc:sqlserver://localhost;instance=SQLEXPRESS. Enter your user credentials, Windows auth or server auth, and make sure you click the text at the bottom that says to download the drivers.
^Note, this will change if you didn't use SQLEXPRESS, change the name to your instance name in MSSM, right click the server and check properties instance name.
15. Choose your authentication type, I used SA.
To use DB with JDBC or SQLJ, JSF etc, import java.sql.*; and use the following lines
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:sqlserver://localhost;instance=SQLEXPRESS; databaseName = surveyData; user = sa; password = xxxxxx;";
Connection con = DriverManager.getConnection(connectionUrl);
Use your user and password, and databasename in the String connectionUrl. I think the drivers for JDBC:ODBC are installed already at this point, but if not, Google jdbc Microsoft SQL Drivers and download from official Microsoft site. It has various drivers for different Java Runtimes, so locate yours matching your Project SDK and add it to libraries. (the specific .jar in the folder)
The connection should work. If you want to test your connection make a main and type something like
if(con != null)
System.out.println("Connection successful");
Hope that can help someone in their coursework.

Related

Microsoft SQL Server , Error : 87

I am really tired, it's been 3 days that I can't open my SQL Server Management Studio. I got connection string error with number 87. Below screenshot show my problem:
And I use localhost\MSSQLSERVER with error 87 and Arash-PC (my machine name) with error number 2.
And I tried sqlcmd -U sa -S Arash-PC too
You need to check in your SQL Server Configuration Manager what services and instances you have installed. Go to Start Menu > All Programs > Microsoft SQL Server (version) > Configuration Tools and launch the appropriate Configuration Manager. You should see a screen something like this:
Find the SQL Server (.....) service(s), and make sure the service is started.
If you find a SQL Server (MSSQLSERVER) service started, then you have a (unnamed) default instance to which you can connect using
.
(local)
Arash-PC
You MUST NOT supply the MSSQLSERVER as the instance name!
If you find any other SQL Server (instance name) service started (e.g. SQL Server (SQLEXPRESS) in my screenshot), then the instance name (SQLEXPRESS) needs to be appended to the server name to connect to that instance:
.\SQLEXPRESS
(local)\SQLEXPRESS
Arash-PC\SQLEXPRESS
Make sure you are not running out of space on the drive where SQL is installed. Try rebooting as well.
Verify that the SQL Server (MSSQLSERVER) service is started. Click Start, click Administrative Tools, click Services, and scroll to SQL Server (MSSQLSERVER). If it is not started, right-click the service, select Properties, in Startup Type select Automatic, click Apply, click Start, and then click OK. Make sure service started. If service did not start - you need to analyze event log. Alternatively - try reinstalling/repairing SQL server.
Make sure you have no network problems - try temporary disabling any firewalls(including Windows Firewall) and antiviruses.
If service is started and firewalls disabled but still no luck - time to check SQL Server Configuration Manager settings. In detail it is described here and here. Shortly I would recommend first enable all protocols in both server and client sections. Reboot. Check it works. If that would not help - then try disabling everything apart from TCP/IP (both server and client sections). Reboot again.
If above does not help - try reinstalling SQL Server. Just make sure you have saved your databases 1st. To save them - stop sql server service, and copy your *.mdf and *.ldf (from SQL server Data folder) files to safe location. Later on you can attach them. If you are not sure where your SQL server Data folder located - just search for files with mdf extension.
Edit:
Successful telnet showing SQL server port is up looks this way:
Edit2:
Launch Event Viewer:
Click System, then Filter Current Log:
Setup filter as shown below:
Then look for SQL-related events:
Usually event text provides information why MSSQLSERVER service fails to start. If the text is unclear please google it for more details.
If your problem was the same as mine (or to anyone else whose attempting to connect to their MS SQL Server w/ a similar connection string), MSSQLSERVER is the default instance name when you set it up, if you don't provide an instance name. I omitted the MSSQLSERVER from the connection string and I was successfully able to connect.
With all respect to "Anton Kruglov" and "marc_s" , Unfortunately, my problem is not resolved . I had to change my windows and reinstall softwares . Now it works properly .

create database permission denied in database ‘master'-sql 2008 R2

So I have installed SQL Server 2008 R2 on windows 7 machine.I was able to login using my windows authentication.Now when I try to create a new database it gives me this error saying "CREATE DATABASE permission denied in database ‘master'".I have tried so many links related to this issue but still it is failing.These are the options that I tried:
1) Went to SQL Server Configuration Manager and then changed the parameters in the advanced tab by adding -m.It still did not help me.When I add this parameter and try to login again using windows authentication it gives me a message saying "Only one administrator can login as it is in single user mode".
2) While Installation I am sure that I added the current user under sysadmin role. I also made sure that the "Mixed mode authentication" is selected and then gave a password for the user "sa".Now when I try to use that password it says "Failed login for user sa".
3) When I login with windows authentication and then check the login mode by following this:
right click on main instance name-->Properties-->Security,it shows that only windows authentication mode is selected.But I am very much sure that I selected the "Mixed mode authentication".Not sure why it is showing it in this way.
4) I also tried to modify the password for sa but the current user has no permissions.I am not able to perform any operation with this user.
I know there are different links for this issue.But I tried all the options that were mentioned in those links but still it is giving me a problem.I have been trying to resolve this issue from a very long time.Could anyone suggest what I am missing here.
Solved! I had the same problem. I figured it out based on info from the article and the comments from the first commentor in this link.
I'll copy the author's steps with the necessary modifications in bold:
Open the Configuration Manager tool from the "SQL Server 2005| Configuration" menu
Stop the SQL Server Instance you need to recover (both SQL Server AND SQL Server Agent. Once in single user mode, if not stoped, the agent will tie up the connection, preventing you from using it with sqlcmd.exe).
In SQL Configuration Manager, click on SQL Server Services on the left, then right click on SQL Server on the right, navigate to the “Advanced” tab (or "Startup Parameters for more recent versions of SQL), and in the Properties text box add “–m” to the end of the list in the “Startup parameters” option.
Click the “OK” button and restart the SQL Server Instance (just SQL Server. Do not restart the SQL Server Agent just yet.) NOTE: make sure there is no space between “;” and “-m”, the registry
parameter parser is sensitive to such typos. You should see an entry
in the SQL Server ERRORLOG file that says “SQL Server started in
single-user mode.”
After the SQL Server Instance starts in single-user mode, the Windows Administrator account is able to connect to SQL Server using
the sqlcmd utility (it is probably here, or someplace very similar: C:\Program Files\Microsoft SQL Server\110\Tools\Binn\SQLCMD.EXE) using Windows authentication. You can use
Transact-SQL commands such as "sp_addsrvrolemember" to add an existing
login (or a newly created one) to the sysadmin server role. The
following example adds the account "Buck" in the "CONTOSO" domain to
the SQL Server "sysadmin" role: EXEC sp_addsrvrolemember
'CONTOSO\Buck', 'sysadmin'; GO
Restart/Start SQL Server Agent, back in the SQL Server Configuration Manager.

cannot connect to pc-name\SQLEXPRESS

While trying to connect to SQL Server 2005 Standard Edition through SQL Server Management Studio 2005 I get the following error:
I put all my effort to solve this problem but there is no solution. On stack overflow in the following post I found this screen shot:
When I see my connect to server dialog box I find the difference like
What is the problem?
This SQL server runs on a single machine, not on a cluster or on a client server.
Go to services (services.msc) and restart the services in the image and then try to connect.
If you have Microsoft Windows 10:
Type Control Panel on Cortana search bar (which is says by default 'Type here to search').
Or click on Windows icon and type Control Panel
Click on Administrative Tools
Then double click on Services
Scroll down and look for: SQL Server (SQLEXPRESS), after that right click
And then in the pop out windows click on Start
Now you should be able to connect to your pc-name\SQLEXPRESS
When you get this error.
Follow these steps then you solve your problem
Open command prompt by pressing (window + r) keys or Click on windows Button and Type Run then type services.msc and click OK or press Enter key.
2.Find SQL Server (SQLEXPRESS).
3.Now see left upper side and click start.
4.If Service show error then right click on SQL Express and then click on Properties.
5.Then click on Logon Tab.
6.Enter Username and Password of Windows Authentication
7.Then Start your Service
8.Problem will be solve and run your query
Use (LocalDB)\MSSQLLocalDB as the server name
Follow these steps then you solve your problem 100%.
When you get this error then close everything(Microsoft SQL Server Managment):
Then open command prompt by pressing (window + r) keys and type services.msc and click OK or press Enter key.
And search **SQL Server (SQLEXPRESS) as I show in the image.
Now see left upper side and click start.
If you open Microsoft SQL Server Management then you not get any type error.
Enjoy!!!
I'm Running Windows 10 and this worked for me:
Open services by searching in the toolbar for Services.
Right click SQL Server (SQLEXPESS)
Go To Properties - Log On
Check Local System Account & Allow service to interact with desktop.
Apply and restart service.
I was then able to connect
Initialize the SQL Server Browser Service.
try using IP instead of pc name. If the ip working, then it might be the name pipe is not enable. If it;s still not working then the login using windows might be disabled.
I had this problem.
So I put like this:
PC-NAME\SQLSERVER
Since the SQLSERVER the instance name that was set at installation.
Authentication: Windows Authentication
Connects !!!
go to services and start the ones related to SQL
My issue occurs when I add a PC to a domain. Restarting the service, making sure it's running, that it has the correct credentials to run, etc, as in other answers doesn't work. I don't know exactly what the problem is, but I can't even log in with the local user anymore to give the domain user access. Here's the steps that work for me:
In SSMS
View > Registered Servers
Database Engine > Local Server Groups > right-click pcname\sqlexpress
Delete > Yes
Right-click Local Server Groups > Tasks > Register Local Servers
It confirms that it re-registered. pcname\sqlexpress reappears.
I'm then able to log in with the local windows auth'd user again, my databases are all there and everything. I then go about my business adding the domain user to Security > Logins.
In my case, I was copying and pasting the server name from appsettings.json as;
DESKTOP-IVQP9DJ\\SQLEXPRESS.
So the problem was that there were two slashes in the server name which was causing the issue for me.
If you are using .net core and copying/pasting server name like me make sure to use only one slash as:
DESKTOP-IVQP9DJ\SQLEXPRESS
If you already did that
Then just restart the service :
start menu
Microsoft SQL Server 20xx
Sql Server 20xx Configuration Manager
SQL Server Service (at left tree)
SQL Server (SQLEXPRESS) (at right region)
right click -> restart

The request failed or the service did not respond in a timely fashion?

I have the following error while I connect to SQL Server 2008 Management Studio with Windows authentication.
"The request failed or the service did not respond in a timely fashion.
Consult the event log or other applicable error logs for details."
Is anybody tell me why i am getting this error, whereas my SQL Server is running under network service built in a/c????
I googled it but not getting solution..
Thanks
Had the same problem, I fixed it.
Open SQL Server Configuration manager
Click on the SQL Server Services (on the left)
Double-click on the SQL Server Instance that I wanted to start
Select the Built-in account radio button in the Log On tab and choose Local system from the dropdown menu
Click apply at the bottom, then right click the instance and select Start
Above mentioned issue happened in my local system. Check in sql server configuration manager.
Step 1:
SQL server Network configuration
step 2:
Protocols for local server name
Protocol name VIA Disabled or not..
if not disabled , disable and check
.. after I made changes the sql server browser started working
This really works - i had verified lot of sites and finally got the answer.
This may occurs when the master.mdf or the mastlog.ldf gets corrupt . In order to solve the issue goto the following path.
C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL , there you will find a folder ” Template Data ” , copy the master.mdf and mastlog.ldf and replace it in
C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA folder .
That's it. Now start the MS SQL service and you are done.
If you are running SQL Server in a local environment and not over a TCP/IP connection. Go to Protocols under SQL Server Configuration Manager, Properties, and disable TCP/IP. Once this is done then the error message will go away when restarting the service.
If you recently changed the password associated with the service account:
Start SQL Server Configuration Manager.
Select SQL Server Services in the left pane.
Right click the service you are trying to start in the right pane and click Properties.
Enter the new Password and Confirm password.
It was very tedious when I get same problem. When I got this problem, I uninstall my SQL Server 2008 but after installing the SQL Server 2008 again,I got the same problem. I was so tensed plus, I had not gotten any help from any site.
To over come this problem. Simply You Need to go on SQL Server Configuration Manager and then click On Protocols on left panel. If you running Network service just disable 'VIA' Protocol.
And after that try to start your SQL service it will run successfully.
After chasing this issue for some hours, we found an log in the SQL Server Agent logs stating the following:
This installation of SQL Server Agent is disabled. The edition of SQL server that installed this service does not support SQL server agent.
We were using SQL Server Express. After some Googling it appears SQL Server Express does not support SQL Server Agent.
I didn't find a direct piece of Microsoft communications stating that SQL Express doesn't support SQL Server Agent, however this sentiment seems to be echoed across many forums.
In my case, the issue was that I was running two other SQL Server instances which were (or at least one of them was) causing a conflict.
The solution was simply to stop the other SQL Server instance and its accompanying SQL Server Agent.
While I'm at it, I'll also recommend making sure Named Pipes is enabled in your server's protocol settings
I had a similar issue. The next solution is in *case to can't launch the server Locally * and you will see the same error msg.(Image 1)
Imagen 1
Imagen 2
To solve that and have the server working you must have the next steps.
Go to SQL Server Services
Right click to open properties
Go to LogOn tab (By default you will see something like Image 3)
Select the radio button Built-in account (Image 4)
Click on Ok
Go back to SQL Server Services and launch again the server (Image 5)
After that you must be able to see run it.
Image 3
Image 4
Image 5
I hope that works for you or others with similar issues. Follow me for more tips.
Just disable the VIA protocol in sql server configuration manager
I found from event logs that My SQL server evaluation has expired.
I needed to upgrade or needed to use community edition.
For me a simple windows update fixed it, I wish I tried it before.
I think this solution is more appropriate, because it does not prevent you from using TCP/IP access.
To open a port in the Windows firewall for TCP access
On the Start menu, click Run, type WF.msc, and then click OK.
In the Windows Firewall with Advanced Security, in the left pane,
right-click Inbound Rules, and then click New Rule in the action pane.
In the Rule Type dialog box, select Port, and then click Next.
In the Protocol and Ports dialog box, select TCP. Select Specific
local ports, and then type the port number of the instance of the
Database Engine, such as 1433 for the default instance. Click Next.
In the Action dialog box, select Allow the connection, and then click
Next.
In the Profile dialog box, select any profiles that describe the
computer connection environment when you want to connect to the
Database Engine, and then click Next.
In the Name dialog box, type a name and description for this rule, and
then click Finish.
(Source: https://msdn.microsoft.com/en-us/library/ms175043.aspx)
I have SQL 2017 installed and this issue happens when the free trial / evaluation period ends, the solution to the problem is the following:
1 - Go to the windows start button, find the Microsoft SQL Server 20XX folder
2- Then, SQL Server 20XX Installation Center
3- On the left, select the option "Maintenance"
4- Then click on “Edition upgrade”
5- Then in the combox select "developer" option, and then click on “next” button
6- Click on the option "I accept the license terms" and then next
7- Finally, click on "Next" and click on "Upgrade", and wait approximately 15 minutes.
8- After this, restart the SQL Server service in "Services.msc" and open SQL again, it should work.
For more information: watch this video: https://www.youtube.com/watch?v=EVG35ahhjec
If you are still scrolling through the answers, here is one more step you might have missed.
Open SQL server configuration manager with admin access.
Apply the changes first(to local System) and then try to run.
If you are configuring your SQL Server connection using Computer Management under Administrative Tools or SQL Server Configuration Manager in Enterprise or Corporate environment,
make sure you open your Computer Management or SQL Server Configuration Manager as an Administrator or you have
Administrative Privileges
All answers above didn't work for me, but when I run it as Administrative mode, I can now start my SQL Server Agent or SQL Server service.
For me happened similar issue when I did uninstall Microsoft Visual C++ 2015-2020 Redistributable and installed the Microsoft Visual C++ 2017 version
Fixed this issue when re-installed Microsoft Visual C++ 2015-2020 Redistrubutable versions. then services started automatically.
Try changing login from different account:
Open SQL Server Configuration Manager as Admin.
Right click SQL sever and SQL Server Integration Services.
Go to Properties and choose Log on.
Choose Built in account.
Select local service.
Apply and Ok.
Start service again.
This is beacuse your both SQL Servers are using same TCP Port Number i.e. 1433 and only one server could run at this port at a time. You have to change or Remove Port number from below settings;
In SQL Server Configuration Manager Click on SQL Server Network Configration.
Click on required Protocols for SQL...
Double click on TCP/IP then select IP Address tab.
Scroldown to end double click in TCP Port Textbox.
Change Port number from 1433 to other one or remove it.
After save these settings now Start your required server.
Good Luck
https://social.technet.microsoft.com/wiki/contents/articles/52394.sql-server-troubleshooting-logon-failure-the-user-has-not-been-granted-the-requested-logon-type-at-this-computer.aspx
event viewer shows
Logon failure - the user has not been granted the requested logon type at this computer

Trouble logging in to SQL2008

I recently installed SQL2008 and am having trouble logging in from another application. I have set the security to shared authentication and have specified a password for the SA login. I am able to log in using SA and password from the management studio and also from command prompt using the osql command, but when trying to log in from third party software (specifically, WhereNet VSS) I get the popup "The SQL Instance Name or login information is not correct. Please try again."
Any suggestions? Unfortunately I cannot install the software until I can successfully log in to the SQL server so it is critical that I get past this ASAP.
Thanks,
Joseph
Did you enable remote connections to your SQL Svr instance (see Server Properties, Connections)? Also, make sure the Windows (or proprietary) firewall isn't interfering w/ connectivity.
Other than allowing remote connections from SQL Server Instance properties --> connections - did you configure remote connections from SQL Server Surface Area Configuration tool? If not you might wanna play with those options to enable remote connections over TCP/IP and/or named pipes.
Also - did you check from the Configuration Manager Tool if TCP/IP properties are properly configured (TCP port properly set, etc.)
Did you try to do the same stuff on another machine and see if with the same settings it works?

Resources