You're using database security for a web application?
<SuppressUrgeToAskWhy />
Here's some sample code snippets you'll have to hack together. It should
give you an idea to begin with.
import java.sql.*;
// Initialize these somehow from your login page...
String uid = userIdFromLoginPage;
String pwd = passwordFromLoginPage;
// Oracle-based example
String url = "jdbc:oracle:thin:@localhost:1521:ORCL" //
Or whatever
boolean loginException = false;
try {
// Register the driver
Class.forName("oracle.jdbc.driver.OracleDriver");
// Try to get a connection
con = DriverManager.getConnection(url, uid, pwd);
} catch( Exception e ) {
// If the database is there, this exception will be thrown because of
invalid credentials
loginException = true;
} finally {
// make sure you close the connection even if the username/password are bad
con.close();
}
// At this point you can make decisions based on the status of
loginException
if (loginException) {
// reject login
} else {
// accept login
}
Also, here's an example of using jdbc to connect to the database using a
username/password if you haven't done it.
http://www.devdaily.com/java/edu/pj/pj010024/
Good luck....
FWIW -
Kevin
"vivek shrivastava" <[EMAIL PROTECTED]> on 04/23/2002 05:43:46 PM
Please respond to "Struts Developers List" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
cc:
Subject: Design Issue for Fisrt Web Application
Hi,
I am an experienced client/server programmer. Now i have to build my first
web
Application using struts. I am giving here a very small description of what
I want to do.
i have to create a report application with few data entry forms. List of
report is based on type of user is logged on. Reports are based on
displayed upon selection.
I am stuck at first step. I don't know how should i perform login
validation. All the logins are database users. Since list of reports based
on user logged on so i am not sure, whether i can use connection pool here
or not? How should i validate the user against database? Should i make a
connection to database or should i do a select on sysusers table?
Please advise me with little detail design help. How should i plan all the
beans( like database access bean , validation bean and all king of bean ).
i
am not asking for code but i am looking for some directional help.
Your help would be appreciated.
thanks
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]
>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]
>
---------------------------------------------------------------------------
This e-mail message (including attachments, if any) is intended for the use
of the individual or entity to which it is addressed and may contain
information that is privileged, proprietary , confidential and exempt from
disclosure. If you are not the intended recipient, you are notified that
any dissemination, distribution or copying of this communication is
strictly prohibited. If you have received this communication in error,
please notify the sender and erase this e-mail message immediately.
---------------------------------------------------------------------------
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>