• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with Connectivity

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have installed Microsoft SQL server on my computer.

using windows authentication it has been installed .

My windows xp username is administrator and has no password

Now I can open my server,execute queries in QueryAnalyzer but unable to connect through java program.

My database tree=>

under SQL server group-->(LOCAL)(windows NT)-->newraj

what is my server name?is it LOCAL or localhost

I have checked the connection with the following program too

Please help me in this regard as soon as possible

JerryIkon

import java.io.*;
import java.sql.*;

public class UBDAO {
private java.sql.Connection con = null;
private final String url = "jdbc:microsoft:sqlserver://";
private final String serverName= "localhost";
private final String portNumber = "1433";
private final String databaseName= "pubs";
private final String userName = "sa";
private final String password = "";


private String getConnectionUrl()
{
return url+serverName+":"+portNumber+";databaseName="+databaseName+";";
}

public static void main(String args[])
{
UBDAO ub = new UBDAO();
Connection con = null;
try
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
con = java.sql.DriverManager.getConnection(ub.getConnectionUrl(),ub.userName,ub.password);
if(con!=null) System.out.println("Connection Successful!");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Error Trace in getConnection() : " + e.getMessage());
}
}
}

I AM GETTING THE FOLLOWING ERRORS:-

java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Log
in failed for user 'sa'. Reason: Not associated with a trusted SQL Server connec
tion.
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source
)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown
Source)
 
Author
Posts: 531
Mac OS X Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
localhost is correct , but you hsould notice that you need to set SQL server authentication to mixed mode , by default it will use windows based authentication which AFAIR is not supported by MS JDBC driver
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic