Solved

JDBC-MSSQL Connection problem. Urgent!!

Posted on 2001-07-17
10
1,003 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

705 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

20 Experts available now in Live!

Get 1:1 Help Now