How to establish a trusted connection with JDBC for SQL SERVER 2000

Hi!I am using jdk 1.4 and eclipse 3.3.

I create a servlet in eclipse with in-build tomcat.

When I run it ,it was working perfectlly has it was suppose to work.

In this servlet I connect to a sql 2000 database using jdbc-odbc bridge driver.

But when I tried to deploy the servlet on tomcat 5.5 manully on the same machine ,it gave me error saying

[Microsoft][SQLServer JDBC Driver][SQLServer]Login failed

for user 'sa'

I searched around some post and found that ok ,I need trusted connection

But I have 2 Questions

1). Why was in eclipse I was able to connect to the SQL server and why not in the servlet which I deployed manully on tomcat.

2). How do I create a trusted connection with JDBC for SQL server 2000

Thnaks for your help in advance.

[819 byte] By [nitin403a] at [2007-11-27 11:15:06]
# 1

Install SQL Server 200 in mixed mode authentication.

setup SAPWD=<sapwd> SECURITYMODE=SQL

dvohra09a at 2007-7-29 14:11:00 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

Install SQL Server 2000 in mixed mode authentication.

setup SAPWD=<sapwd> SECURITYMODE=SQL

dvohra09a at 2007-7-29 14:11:00 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

Sorry buddy but I think you R not reading my Q? properly.

I know I need to Install the sql server in mixed mode.

But Q? is

Y the same code in eclipse is able to connect the database

and not the servlet which I deployed normally as per the tomcat deploying process?

Secondly the server which I am trying to connect is not my father's property so I will always able to reinstall the SQL server or change it to mixed mode.

What I think is eclipse is using some library file(jar file) to connect the SQL server which I don't know.

Sorry but your Answer is no good to me.

nitin403a at 2007-7-29 14:11:00 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

> Sorry buddy but I think you R not reading my Q? properly.

First of all, he's not your buddy.

Second of all, it's a reasonable answer to a poorly worded question.

> I know I need to Install the sql server in mixed mode.

>

> But Q? is

> Y the same code in eclipse is able to connect the

> database

> and not the servlet which I deployed normally as per

> the tomcat deploying process?

Maybe you don't know how to deploy servlets, run tomcat, or connect to databases properly.

> Secondly the server which I am trying to connect is

> not my father's property so I will always able to

> reinstall the SQL server or change it to mixed mode.

Exactly.

> What I think is eclipse is using some library

> file(jar file) to connect the SQL server which I

> don't know.

Like maybe the JDBC driver?

> Sorry but your Answer is no good to me.

Your question isn't very good, either.

%

duffymoa at 2007-7-29 14:11:00 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5

Try visiting this link...

I had the same problem of creating a connection with MS SQL Server 2000, but the difference is that i'm using JDeveloper 10.1.3 ,,

and the way is on this site, and it completely worked with me..

http://www.oracle.com/technology/products/jdev/howtos/bc4j/bc_psqlserverwalkthrough.html

QussayNajjara at 2007-7-29 14:11:00 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 6

To $TOMCAT_HOME/conf/tomcat-users.xml

add:

<tomcat-users>

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

</tomcat-users>

dvohra09a at 2007-7-29 14:11:00 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 7

> To $TOMCAT_HOME/conf/tomcat-users.xml

> add:

> <tomcat-users>

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

> /tomcat-users>

Utter nonsense.

How is this communicated to the database? Tomcat doesn't know anything about databases.

%

duffymoa at 2007-7-29 14:11:00 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 8

Thanks for the correction.

To configure a SQL Server data source in Tomcat specify the SQL Server username in conf/server.xml.

http://www.inetsoftware.de/products/jdbc/mssql/configuration/tomcat/

dvohra09a at 2007-7-29 14:11:00 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 9

That's a better idea.

%

duffymoa at 2007-7-29 14:11:00 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 10

Hi! duffymo ,QussayNajjar ,dvohra09 .

Thank for help.

The ideas are really great.

I am trying generate reports for my company.

When I used eclipse the code worked perfectly.

below is code which I used

out.println("Calling For Class Name

");

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

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

");

1). jdbcConnection = DriverManager.getConnection("jdbc:odbc:SQLJasper");

2). jdbcConnection = DriverManager.getConnection("jdbc:odbc:Driver={SQL Server};Server=ServerName;Database=tempdb");

3). jdbcConnection = DriverManager.getConnection("jdbc:odbc:Driver={SQL Server};Server=ServerName;Database=tempdb","UID=UserName","Password=Password");

out.println("connecting to database success

");

I had tried to connect the database using this three way.

In 1st I tried using DSN name .

Next 2 self explainer for expert like you.

I used to 2nd variant to connect in eclipse and it worked fine.

I not an expert in java ,I just doing some research on jasperReport.

My best guest is that eclipse is using some library files of which I have no clue.

Thank's for your help,I appretiate it.

Once again thank a billion.

Sorry for the messy righting.

nitin403a at 2007-7-29 14:11:00 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 11

Hi! guy's

I am able to connect the sql server after some help from the system guys.(Well I got the sa password and now the servlet rocks)

The server was in the mixed mode.

I have an Question for U.

I used IReport to create my template for a report.

In that I query the database using an SQL statement and it show me the avalible columes.

The PC on which the SQL server is there, I have access to that.

In IReport I don't pass my loginID or password.

So some how it creates trusted connection with the server using windows auth.

My Question is how does it or I can creates trusted connection for the users how have access to the server using windows authentication.

Thank a lot for your help.

nitin403a at 2007-7-29 14:11:00 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...