Error 18452 and other problems

Posted on 2007-10-11
Medium Priority
Last Modified: 2010-08-05
I am trying to connect from Linux to SQL Server 2005. I'm using the following line in my jsp program:
con = DriverManager.getConnection( dbURL2);

If my dbURL2 is:
Connection Failed. Status: 18452

If I change the server portion of the string to: "" I get:
Connection Failed. Status: 0
but it still throws the SQLException exception and my con is null. I do have the SQL Server authentication set to 'SQL Server and Windows Authenication Mode'

What's wrong?
Question by:jmarkfoley
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 20063355
try this\TRAVERSE105
LVL 26

Expert Comment

ID: 20063382
try this,

String conURL = "jdbc:sqlserver://;database=OSH2007;"

and give the username and pwdin the getConnection method,

DriverManager.getConnection( conURL , "hprs/mark", "12345" );

Author Comment

ID: 20069068
aneeshattingal: that didn't work: 18452
ksivananth: I had tried that previously. That didn't work: 18452

I'm trying to use my own Windows login Id. Should I create a special Id just for this?

Also, this is a bit annoying, but slightly off topic: I am running this test program in my context directory unpacked on a Linux host. On this Windows Back Office server, it often doesn't refresh the browser from the modified jsp program. I get the same display and strings from previous versions of the program. I generally have to copy my .jsp to a new file name in order to run it. What's up with that? I've got the brower set to check for modified pages every time. This didn't happen when I browsed with my own XP workstation.

Author Comment

ID: 20069358
OK, I created a new SQL Server login that is specifically 'SQL Server Authentication'. Same 18452 problem. Connection String:

When I changed the connection string to:

I got: "Cannot Open User Default Database (error 4064)" The MS KB lists causes:
" Is in suspect mode.
" No longer exists.
" Is in single user mode and the only available connection is already being used by someone else or by something else.
" Has been detached.
" Has been set to the RESTRICTED_USER state.
" Is offline.
" Is set to emergency status.
" Does not have the login account mapped to a user or the user has been denied
" Is part of a database mirror.

The only possibility here appears to be "Does not have the login account mapped to a user or the user has been denied access." I'm winging the dba stuff. Does this info give anyone a clue? Maybe some of you SQL Server DBA types?
LVL 42

Accepted Solution

dqmq earned 2000 total points
ID: 20071361
After creating a login, go to the User Mapping tab and indicate the database-user combinations that you want to give that login access to. It's an especially critical step to map a user to the default database.
Right click:  Security->Logins->YourLogin
Left click: Properties
Select: User Mapping  tab;  Check the box for YourDB.

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question