Suggest me a full JSF with Database Connectivity Program

Hi

I am new to JSF.

I Know JSP like how to connect with database using JDBC.

when i am trying the same using JSF how can i connect to the database For e.g., Login Page accessing the username and password from the database.

I would like to use Mysql as a database.

Pls can anyone suggest me in this.

Thanks in advance

Ambika.

[373 byte] By [ambika_devia] at [2007-11-27 7:40:33]
# 1

Hi,

i came across u r prblm its very simple to connect to database.

Iam giving sample apllication just follow this

import java.sql.Connection;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

import javax.naming.Context;

import javax.naming.InitialContext;

import javax.naming.NamingException;

import javax.servlet.jsp.jstl.sql.Result;

import javax.servlet.jsp.jstl.sql.ResultSupport;

import javax.sql.DataSource;

public class CustomerBean {

private Connection conn;

public void open() throws SQLException, NamingException {

if (conn != null) return;

Context ctx = new InitialContext();

DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/mydb");

conn = ds.getConnection();

}

public Result getAll() throws SQLException, NamingException {

try {

open();

Statement stmt = conn.createStatement();

ResultSet result = stmt.executeQuery("SELECT * FROM Customers");

return ResultSupport.toResult(result);

} finally {

close();

}

}

public void close() throws SQLException {

if (conn == null) return;

conn.close();

conn = null;

}

}

venkatJSFa at 2007-7-12 19:21:04 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Hi,try this one i think it helps u lot.. http://www.oracle.com/technology/pub/articles/cioroianu_jsfdb.html
venkatJSFa at 2007-7-12 19:21:04 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...