Unable to connect the SQL database from servlet

Hi!

My servlet connects with an SQL server on some other machine.

I have create the servlet and deploy it on tomcat.

I first create this servlet on eclipse that I deploy it on tomcat manually.

While using it form eclipse it gave no error in connecting with the server.

But when I deploy the same code on tomcat manually and access the page it gave me an error saying

[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'

I used the following code for cenneting the server

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

out.println("Calling For Class Name success Now calling database

");

jdbcConnection = DriverManager.getConnection("jdbc:odbc:Driver={SQL Server};Server=MyServerName;Database=MyDatabaseName","","");

Message was edited by:

nitin403

[886 byte] By [nitin403a] at [2007-11-27 11:11:33]
# 1

plz show me that part of you code...

just copy paste it...

i cant realy understand much from whatever u have written....

Mr.VijayDesai@OPSPLa at 2007-7-29 13:48:58 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

Hi!

Sorry for not formating my previous message properly.

My servlet connects with an SQL server on some remote machine.

I have create the servlet and deploy it on tomcat.

I first create this servlet on eclipse that I deploy it on tomcat manually.

While using it form eclipse it gave no error in connecting with the server.

But when I deploy the same code on tomcat manually and access the page it gave me an error saying

[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'

I used the following code for connecting the server

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

jdbcConnection = DriverManager.getConnection("jdbc:odbc:Driver={SQL Server};Server=MyServerName;Database=MyDatabaseName","","");

Thanx for your help in advance

Message was edited by:

nitin403

nitin403a at 2007-7-29 13:48:58 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

Install SQL Server 2000 in mixed mode authentication.

dvohra09a at 2007-7-29 13:48:58 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

Thanks for your help.

I learn it form other post about the windows auth.

But I still don't find the how eclipse is able to do the same thing by the same code and my servlet is not able to do that.

If there is some thing wrong it my code please point that out.

I would also like to add that it is not possible for me to always change the auth of windows or reinstall the sql server in mixed mode.

So I need to find how to connect the server in the above condition.

Thanks for your help once again.

Hope to hear from U soon.

nitin403a at 2007-7-29 13:48:58 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5

To $TOMCAT_HOME/conf/tomcat-users.xml

add:

<tomcat-users>

<user name="sa" password="tomcat" roles="role1" />

</tomcat-users>

dvohra09a at 2007-7-29 13:48:58 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...