Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

JDBC-MSSQL Connection problem. Urgent!!

Posted on 2001-07-17
10
Medium Priority
?
1,028 Views
Last Modified: 2007-12-19
Hi,
I am having problem in connection to MS SQL 2000 Eval version using Merant JDBC Driver.
Below is the code i am using ..

/**********************CODE******************/
import java.sql.*;

class sqlTest{
public static void main(String args[]){
     System.out.println("Connecting to SQL Server 200 : Localhost");
     try {
    Driver d = (Driver)Class.forName("com.merant.datadirect.jdbc.sqlserver.SQLServerDriver").newInstance();
} catch (Exception e) {
    System.out.println(e);
     System.exit(0);
}

// GET CONNECTION
Connection con;
try{
    con = DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433","administrator","admin");
}catch(SQLException e){
         System.out.println("Error : "+e.getMessage());
     System.exit(0);


}
}
}
/**********END CODE****************/

I get the follwoing error..
Error : [MERANT][SQLServer JDBC Driver][SQLServer]Login failed for user 'administrator'.

My SQL server is configurd to work with windows authentication as well as SQL server authentication, though i use windows administrator login. The server is installed on localhost, with both named pipes and tcp on port 1433.

What am i missing?
Please help.
0
Comment
Question by:skullface
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 1

Expert Comment

by:chrhedga
ID: 6288832
Well, I am not familiar with Java and connecting to SQL Server through JDBC, but it seems to me that you're trying to connect to your SQL Server using a SQL Server login, although you're specifying a Windows NT user account. If you want to connect using Integrated Security (Windows NT account) don't specify a username and password, your application will connect using the user context it is running in.
0
 
LVL 3

Expert Comment

by:ibro
ID: 6288833
Try this:
con = DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433","MYDOMAIN\administrator","admin");
0
 

Author Comment

by:skullface
ID: 6289176
chrhedga:
no it not working.. it gives me the following error:
Connecting to SQL Server 200 : Localhost
Error : [MERANT][SQLServer JDBC Driver][SQLServer]Login failed for user '(null)'
. Reason: Not associated with a trusted SQL Server connection.

ibro
my win2000 machine is on an intranet behind a firewall..
and its a part of a workgroup called IC..
i am not sure if i am able to understand what u said..  
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Expert Comment

by:ibro
ID: 6289302
Expression MYDOMAIN\administrator is the name of the NT domain, which your server is part of. If you try to connect to localhost (same machine) use replace MYDOMAIN with COMPUTER_NAME\Admistrator, where COMUTER_NAME is the name of your localhost.

You can also set "sa" password if you can connect with Enterprise manager and try to logon as "sa" like:
con = DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433","sa","password");

Please let me know if you can connect to sql server with Query analizer or Enterprise manager. Check your network protocols with Client Network Utility from SQL Server package.
 
0
 

Author Comment

by:skullface
ID: 6290313
i can use all functionalities of the SQL server..
enterprise manager, query analyser.. i am using win2000 authentication.. it workes perfectly..

i have tried with my machine name, workgroup name.. nothing works..
how do i set the sa password???
thats the option left..

otherwise.. i am shitfing my development on DB2.. its much better than this.. atleast with JDBC..

have wasted lot of time looking for solutions.. :((
0
 
LVL 3

Accepted Solution

by:
ibro earned 280 total points
ID: 6292537
To set sa password:
Open Enterprise manager and login as administrator (if you are not already logged). Go to Security/Logins. Find sa on right panel and double-click on it. Enter new password on Passwrod field and press OK. After that confirm the password.
0
 
LVL 3

Expert Comment

by:ibro
ID: 6292548
btw if you want you can get another JDBC driver for SQL2000. I'm using it and it's working fine:
http://commerce.bea.com/downloads/weblogic_server.jsp#wlsjdbc
I can send you some some code to connect if you want.
0
 

Author Comment

by:skullface
ID: 6292853
IT WORKED.. yipeeeeee :))))))

sa worked..
thanx ibro..
i am still not able to use windows authentication . but this will do ..

i have necver used weblogic.. before.. iuse Resin and JBoss for all my work.. (both are free :) )
the weblogic driver also have 30 day user license along with only 2 simultaneous connections..

anyways .. i am very much satisfied with DB2.. i think i will stick to it .. bcoz of its portablility.. at least is also available on Linux..

thanx a lot ..
here are the points..
0
 
LVL 3

Expert Comment

by:ibro
ID: 6292887
I'm glad it worked... Anyway..I know the SQL server is not perfect, but it has its own good points - simplicity....
I also preferer other databases (Oracle on Unix/Linux), but company policy is different...:((
0
 

Author Comment

by:skullface
ID: 6293865
i agree. to it.. in DB2 things are a little complex than in SQL server.. at least with a 5 day experience with db2 thats what i felt..
thanx anyway..
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

618 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