Solved

JDBC-MSSQL Connection problem. Urgent!!

Posted on 2001-07-17
10
1,014 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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 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

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Regarding Disk IO 3 49
SQL Query Returns Records in SSMS but not Classic ASP 5 26
SQL query 7 18
Estimating my database size 7 17
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
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…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how the fundamental information of how to create a table.

733 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