Error 18452 and other problems

Posted on 2007-10-11
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
    try this\TRAVERSE105
    LVL 26

    Expert Comment

    try this,

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

    and give the username and pwdin the getConnection method,

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

    Author Comment

    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.
    LVL 1

    Author Comment

    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

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
    The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
    Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
    Via a live example, show how to shrink a transaction log file down to a reasonable size.

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now