473,396 Members | 1,915 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

accessing databases

TP
Hi,

I am doing my first database project using java servlets.

We are going along fine but I have a question about how should one
access a database.

We have the URL, userid and pwd in a text secured file or maybe in
web.xml. somewhere where the user does not access it.

The argument is that my colleague thinks (who is also doing his first
db project) that the userid and pwd should be dynamic, like something
that the user should provide everytime he wants anything from the
database.

So how should it be, once for each servlet or once every connection?

Thanks.

TP.
Nov 12 '05 #1
5 1511
Depends on what sort of security you want, and how sensitive the data
is. Amazon lets me create a new userid and password everytime I sign on.
I doubt an online bank would permit that.

TP wrote:
Hi,

I am doing my first database project using java servlets.

We are going along fine but I have a question about how should one
access a database.

We have the URL, userid and pwd in a text secured file or maybe in
web.xml. somewhere where the user does not access it.

The argument is that my colleague thinks (who is also doing his first
db project) that the userid and pwd should be dynamic, like something
that the user should provide everytime he wants anything from the
database.

So how should it be, once for each servlet or once every connection?

Thanks.

TP.


Nov 12 '05 #2
TP
Any other ideas people. This is a question from an inexperienced
person dealing with databases.

Thanks.

tP.
Blair Adamache <ba*******@2muchspam.yahoo.com> wrote in message news:<bv**********@hanover.torolab.ibm.com>...
Depends on what sort of security you want, and how sensitive the data
is. Amazon lets me create a new userid and password everytime I sign on.
I doubt an online bank would permit that.

TP wrote:
Hi,

I am doing my first database project using java servlets.

We are going along fine but I have a question about how should one
access a database.

We have the URL, userid and pwd in a text secured file or maybe in
web.xml. somewhere where the user does not access it.

The argument is that my colleague thinks (who is also doing his first
db project) that the userid and pwd should be dynamic, like something
that the user should provide everytime he wants anything from the
database.

So how should it be, once for each servlet or once every connection?

Thanks.

TP.

Nov 12 '05 #3
tp******@hotmail.com (TP) wrote in message news:<59**************************@posting.google. com>...
We have the URL, userid and pwd in a text secured file or maybe in
web.xml. somewhere where the user does not access it.

The argument is that my colleague thinks (who is also doing his first
db project) that the userid and pwd should be dynamic, like something
that the user should provide everytime he wants anything from the
database.


I don't think that storing your userdata in a file is very practical.
You'll run into trouble if multiple threads try to update the file
(e.g. a new user is registered).

I suggest you to specify to db users, a web user and a system user.
The system user maintains a table with the user data (and passwords).
This table is only readable for the system user. The servlet will use
the web user to login into the database. If the web user wants to
authorize a login request, it calls a stored procedure created by the
system user which checks the provided login data against the table and
returns wether the data is correct (= login ok) or not. Use the
servlet's http-session to indicate if a user has successfully provided
his login data or not.

This way, your user data and passwords remain in a maintainable format
(db table) and the password isn't readable in case your web
application contains a sql-injection vulnerability.
hth
Nov 12 '05 #4
TP
Thats a really good idea.

This is what my situation is, we use db2 database to retrieve
information as a second step from an already created web application
which has its login procedures. (as a portlet maybe) so basically when
a user wants to access db2 he has already been authenticated into the
system.

the way that we are using db2 is, we store the required user id and
pwd information in web.xml, retrieve it on init(), store it in
httpsession and send it to db2 on ever db transaction.

so in this case threading will not be an issue (bcoz of httpsession)

so according to you, is what we are doing valid? wud like some
comments.

Thanks.

TP.
ny***@gmx.net (Almund Sebi) wrote in message news:<94**************************@posting.google. com>...
tp******@hotmail.com (TP) wrote in message news:<59**************************@posting.google. com>...
We have the URL, userid and pwd in a text secured file or maybe in
web.xml. somewhere where the user does not access it.

The argument is that my colleague thinks (who is also doing his first
db project) that the userid and pwd should be dynamic, like something
that the user should provide everytime he wants anything from the
database.


I don't think that storing your userdata in a file is very practical.
You'll run into trouble if multiple threads try to update the file
(e.g. a new user is registered).

I suggest you to specify to db users, a web user and a system user.
The system user maintains a table with the user data (and passwords).
This table is only readable for the system user. The servlet will use
the web user to login into the database. If the web user wants to
authorize a login request, it calls a stored procedure created by the
system user which checks the provided login data against the table and
returns wether the data is correct (= login ok) or not. Use the
servlet's http-session to indicate if a user has successfully provided
his login data or not.

This way, your user data and passwords remain in a maintainable format
(db table) and the password isn't readable in case your web
application contains a sql-injection vulnerability.
hth

Nov 12 '05 #5
And if needed, you can use the encrypt and decrypt functions in DB2 to
encrypt any password data you store in a table.

Almund Sebi wrote:
tp******@hotmail.com (TP) wrote in message news:<59**************************@posting.google. com>...
We have the URL, userid and pwd in a text secured file or maybe in
web.xml. somewhere where the user does not access it.

The argument is that my colleague thinks (who is also doing his first
db project) that the userid and pwd should be dynamic, like something
that the user should provide everytime he wants anything from the
database.

I don't think that storing your userdata in a file is very practical.
You'll run into trouble if multiple threads try to update the file
(e.g. a new user is registered).

I suggest you to specify to db users, a web user and a system user.
The system user maintains a table with the user data (and passwords).
This table is only readable for the system user. The servlet will use
the web user to login into the database. If the web user wants to
authorize a login request, it calls a stored procedure created by the
system user which checks the provided login data against the table and
returns wether the data is correct (= login ok) or not. Use the
servlet's http-session to indicate if a user has successfully provided
his login data or not.

This way, your user data and passwords remain in a maintainable format
(db table) and the password isn't readable in case your web
application contains a sql-injection vulnerability.
hth


Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Benedictum | last post by:
How do I access data from a database located in a server somewhere with an application running on a local machine?
3
by: Scott Castillo | last post by:
Is it possible to access an SQL Server database from a Javascript client? I know you can transfer variables from middleware to Javascript client, but was wondering if you can directly access...
3
by: TS | last post by:
I am very new to .Net. I have good experience with VB, but I'm still in an early stage of learning .Net plattform. Anyway, I don't know if I'm asking this in the correct newsgroup, but if I'm not,...
1
by: Jim Richards | last post by:
Hello all. I have just built another PC (New PC)and have it connected to my Original PC via a LAN. I have my SQL Server 2000 installed on the Original PC. Both PCs use WinXP Pro OS. I believe I now...
2
by: Douglas Harber | last post by:
If I have DB2 8.1 (FP5, I believe, but not relevant to my question...I hope) installed on my desktop, do I have what I need to connect to a remote DB2 server (also running 8.1 FP5) from my desktop...
10
by: Andrea M. Segovia | last post by:
Hello, I am a newbie to Oracle databases.... We have a visualization front-end tool connected to an Oracle back-end database on a Tru64 UNIX server. We also have clients with MS access...
5
by: David Garamond | last post by:
I am setting up a single PostgreSQL installation to be used by several users. Can I restrict a database user from connecting and creating objects in other databases but his/her own? So far I can...
5
by: samadams_2006 | last post by:
I'm having a problem in accessing a Microsoft Access Database in a VB.NET Web Application. It's so straight forward, I thought I'd walk you through all the details here: 1) I have a .NET Web...
0
landy
by: landy | last post by:
Hi all! Here is my issue - I have a linux box set up as the server for the external webpage for my organization using apache/PHP to write the pages. I also use MySQL on this box for storing...
4
by: Noy B | last post by:
Hi, I have developed a small application that is using a MSAccess DB. the problem is that it was developed on a machine where the application and the DB are both located. now it needs to be...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.