• 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

Why this Program throws SQLException

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers ,
Why this program throws SQLException
Although I put all classes and jar files in class path
the error is

111 java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.


import java.sql.*;

class jdbc
{
public static void main(String[] args)
{
try
{

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection con=DriverManager.getConnection("jdbc:microsoft:sqlserver://209.172.34.240:1433;databaseName=Northwind,user=ossqluser,password=os34sql");
con.close();
System.out.println("Connection Success..!!!");
System.exit(0);
}
catch(ClassNotFoundException eclass)
{
System.out.println("Driver Not Found ! "+eclass);
}
catch(SQLException esql)
{
System.out.println("111 "+esql);//.getMessage());
}
}
}
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.



What authentication method is your SQL instance configured to accept? If you are using the older Microsoft SQL Server driver you have to have the server configured to accept both SQL Server and Windows Integrated authentication, not just Windows Integrated.
 
swarupa patil
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didnot understand ur meaning of
SQL server authentication and windows authentication
Where from we get these both.
Please reply ASAP
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
SQL Server 2000 has two methods it can use for authentication. Either Windows Integrated authentication, which authenticates a user based on their NT/AD accounts, or SQL Server authentication which authenticates a user based on the username and password defined as a login on the server instance. The older Microsoft driver can only work with SQL Server authentication so you have to configure your server instance to allow that kind of authentication mechanism. If you are still not sure what I am talking about, or don't know how to change this I suggest you take some time to read the SQL Server documentation, specifically the secion about authentication.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic