DATABASE  as Authentication Data Source

 

SQL Table format:

                 USERID          VARCHAR(20) PRIMARY KEY
                PASSWORD     VARCHAR(20) NOT NULL
                LNAME             VARCHAR(30)
                FNAME             VARCHAR(30)
                EMAIL               VARCHAR(50)

To run the sample application Download the project files from http://sourceforge.net/projects/sfg/ here

Unpack the file under web application directory (webapps/)

Change the  authenticate/WEB-INF/Web-jdbc.xml into web.xml

According to your database in web.xml change JDBC Driver class, Database connection URL, database user name and password.

<init-param>
<param-name>jdbcDriverClassName</param-name>
<param-value>org.gjt.mm.mysql.Driver</param-value>
</init-param>
<init-param>
<param-name>jdbcURL</param-name>
<param-value>jdbc:mysql://localhost:3306/test</param-value>
</init-param>
<init-param>
<param-name>dbUserName</param-name>
<param-value>sundaram</param-value>
</init-param>
<init-param>
<param-name>dbUserPassword</param-name>
<param-value>sun123</param-value>
</init-param>

logon to database and create the user table ( SQL script you can find WEB-INF/data/userinfo.sql file)

insert some sample record in that table commit and exit from the database

Than start the web server and point your browser to http://localhost/authenticate/ URL you should be able to see index page.

Before starting the web server make sure you have database driver jar file in your class path.

To Debug please look into log file and web server console message.

This program tested with Oracle and MySQL database.