• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1033
  • Last Modified:

JDBC-MSSQL Connection problem. Urgent!!

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
skullface
Asked:
skullface
  • 5
  • 4
1 Solution
 
chrhedgaCommented:
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
 
ibroCommented:
Try this:
con = DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433","MYDOMAIN\administrator","admin");
0
 
skullfaceAuthor Commented:
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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
ibroCommented:
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
 
skullfaceAuthor Commented:
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
 
ibroCommented:
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
 
ibroCommented:
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
 
skullfaceAuthor Commented:
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
 
ibroCommented:
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
 
skullfaceAuthor Commented:
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now