Solved

JDBC-MSSQL Connection problem. Urgent!!

Posted on 2001-07-17
10
1,005 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
  • 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
 
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
[Webinar] Disaster Recovery and Cloud Management

Learn from Unigma and CloudBerry industry veterans which providers are best for certain use cases and how to lower cloud costs, how to grow your Managed Services practice in IaaS clouds, and how to utilize public cloud for Disaster Recovery

 
LVL 3

Accepted Solution

by:
ibro earned 70 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

910 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

22 Experts available now in Live!

Get 1:1 Help Now