Cannot connect to sql server 2008 using JDBC - sql

I have tried all the methods to connect to the server.I am using sql server 2008 on mixed authentication mode.I can login via the sql server management studio using the sa login.But when I try accessing the same db from my java program I get the following error:
SQL Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'sa'. ClientConnectionId:191d94bb-a55e-47a0-bb9f-b84638313cf4
This is my connectionstring:
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl= "jdbc:sqlserver://localhost;databaseName=Northwind;user=sa;password=sa;";

I have accessed my database in the same way. One of my problems were that I hadn't enabled the port and IP for the database. Check these options in SQL Server Configuration Manager. Hope this helps =)

Related

Error connecting to new sql server

I am facing problem in registering new sql server instance SQLEXPRESS in SQL Management studio 2008. when I try to connect or test the server error message appear,
I am also facing facing same problem in any new server irrespective of the name, except the main one which was created at the time of installation and which was named same as my user ID in windows..
TITLE: Microsoft SQL Server Management Studio
Error connecting to 'SQLEXPRESS'.
ADDITIONAL INFORMATION:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 53)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=53&LinkId=20476
are you using windows authentication or sql server authentication
if you are using windows authentication then you have to give the sql instance name
which sql provide by default .
if you using sql authentication then u must use the username and password which
you provide during setup

Connection string failing for SQL server 2012

I'm trying to connect to my db on my local machine with the following connection string and it fails for the following connection string
conn = new SqlConnection("Server=(local);DataBase=dnn6;Integrated Security=SSPI");
I'm using IIS 6 as my web server and when I open that page I get the following error.
Cannot open database "dnn6" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\demo'.
I'm using SQL Server 2012
The problem is that the IIS account being used to access SQL Server (IIS APPPOOL\demo) does not have access to it.
You need to either:
grant permission for the user IIS APPPOOL\demo to your SQL Server
use impersonation to connect to SQL Server with a user account that has access
use SQL Server Logins to access SQL Server using a named user (not recommended these days)

Cannot login to sql server 2008 R2 after rebooting server

I am using Windows-server-2008 with Microsoft SQL Server 2008.
And there are a lot of questions about this, but nothing on the internet solved it.
The problem is that i can't connect to the my SQL Server 2008 R2 after rebooting my server.
I placed some new memory in my server, and after rebooting my client/server application didn't work anymore because it cannot reach the database.
So i tried to get in SQL Server Management Studio (SSMS), and tried to loggin with Administrator and another user but both do not work.
When i logg in the following message is displayed:
Cannot connect to (local)
A network-related or instance-specific error occurred while establishing a connection
to SQL Server. The server was not found or was not accessible. Verify that the instance
name is correct and that SQL Server is configured to allow remote connections.
(provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
(Microsoft SQL Server, Error: 2)
I Tried a lot of different things like:
Rebooting server
Try to start the server manually from Sql Server Configuration Manager
Named Pipes - Enabled
TCP/IP - Enabled
Tried to create an new system user or database user as described in the following article: Click Here
Can somebody please help me? I am really confused because i need to get this online. Otherwise i have to reinstall the database server but i do not have a back-up. (is there some folder with a back-up of the settings/tables/columns are stored and can be imported from reinstall?
I was having the exact same problem. net start mssqlserver was giving me the blurb about a failed login attempt. The problem was that I had recently changed the password for the administrator account, and the new password didn't get updated in services.
Here's how I fixed it:
First locate SQL Server from the list here:
Right click and select properties, and navigate to the Log On tab:
Then I typed the new password, and like magic I was able to start SQL Server right through the services manager.
I also did this for any other processes which were marked as "stopped" even though Startup Type was marked as "automatic" (namely, SQL Server Agent).
Is it a named instance or default? Also, is this a local instance? (I see the "(local)" but just wanted to make sure.)
Start the sql server services from services.msc and try to connect

SQL Server 2008 erroneously returning SQL Authentication failed

I am attempting to connect to SQL via SQL authentication. On SQL Server I receive Login succeeded, yet via code I get Login failed for user 'geneva'. I verified the login in SSMS and am able to connect via Windows authetnication. The sql user has full rights. Tried via java/.net code, really unsure why I am unable to connect via SQL Auth.
Data Source=server;Initial Catalog=GenevaWorkflow;User ID=user;Password=password
The environment is SQL Server 2008/Windows 2008. Very frustrating being all I want is to connect via SQL authentication and SQL Server I set to mixed mode authentication.
Enable sql logins in server properties (from management studio) and restart sql server.

How to login to SQL Server 2005 Express Management Studio?

I've just installed SQL Server 2005 Express and I'm trying to login to Management Studio but I don't know what the "Server Name" is to be able to login.
I've tried:
localhost\SQLEXPRESS
127.0.0.1\SQLEXPRESS
SQLEXPRESS
<computer name>\SQLEXPRESS
<username>\SQLEXPRESS
The authentication mode is Windows Authentication.
The error message I'm getting is:
Could not connect to <computer name>\SQLEXPRESS.
Additional information
A network related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (proveder: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (Microsoft SQL Server)
Does anyone point me in the right direction?
Is the SQL Server Express service even up and running??
The local machine can be defined as . or (local) for SQL Server, and the SQL Server Express instance name is SQLExpress by default.
So .\SQLExpress or (local)\SQLExpress ought to work.
If they don't, maybe the service isn't up and running??