how do i connect to Mysql using EJB3
hi i have created the following jsp pages now how do i connect to database and write the SESSION BEAN and ENTITY BEAN using EJB3
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<f:view>
<!-- <f:loadBundle basename="com.fms.fins.web.Application" var="msgsApp" /> -->
<head>
<title>My JSF 'SearchListLaw' starting page</title>
</head>
<body>
<h:form id="searchForm" rendered="true">
<table align="left" cellspacing="0" cellpadding="0">
<tr>
<td>
<h:commandButton value="ADD" action="addlaw" type="submit" />
</td>
<td>
<h:commandButton id="EDIT_ID" value="EDIT" action="editlaw" type="submit" />
</td>
<TD>
<h:commandButton id="DELETE_ID" value="DELETE" type="submit" />
</TD>
<td>
<h:commandButton value="VIEW" id="VIEW_ID" action="viewlaw" type="submit" />
</td>
</tr></table>
<table>
<tr>
<td>
<h:outputText value="Law_ID:"/>
</td>
<td>
<h:inputText id="Law_id" />
</td>
</tr>
<tr>
<td>
<h:outputText value="Law_Description:"/>
</td>
<td>
<h:inputText id="Law_desc_id" />
</td>
</tr>
<tr>
<TD>
<h:commandButton id="SEARCH_ID" value="SEARCH" type="submit" />
</td>
<td>
<h:commandButton value="RESET" rendered="true" type="reset" id="RESET_ID" />
</td>
</tr>
</table>
<h:dataTable summary="Component Listing" border="1" id="Component" value="#{ComponentListing.items}" var="component">
<h:column>
<h:selectOneRadio value="raidoButton" onclick="selectOne(this.form, this)">
</h:selectOneRadio>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Law_id"/>
</f:facet>
<h:outputText value=""/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Law_Description"/>
</f:facet>
<!-- <h:commandLink id="link" action="#{ComponentListing.gotoComponentDetail}" onclick="setLinkComponentID(#{component.componentID})">-->
<h:outputText value=""/>
<!-- </h:commandLink> -->
</h:column>
</h:dataTable>
</h:form>
</body>
<script language="javascript">
function selectOne(form, button){
turnOffRadioForForm(form);
button.checked = true;
}
function turnOffRadioForForm(form){
for(i=0; i<form.elements.length; i++){
form.elements.checked = false;
}
}
/*function setLinkComponentID(value){
document.all['_id0:hiddencomponentID'].value = value;
}*/
/*
function confirmation(){
var a = MessageBox("Are you sure you want to delete?", "Delete", 4);
if (a==1){
return true;
} else {
return false;
}
}
*/
></script>
</f:view>
</html>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<f:view>
<!-- <f:loadBundle basename="com.fms.fins.web.Messages.Application" var="msgsApp" /> -->
<head>
<title>My JSF 'AddLaw.jsp' starting page</title>
</head>
<body>
<h:form id="searchForm" rendered="true">
<table align="left" cellspacing="0" cellpadding="0">
<tr>
<td>
<h:commandButton id="save_id" value="SAVE" rendered="true" />
</td>
<td>
<h:commandButton id="edit_id" value="EDIT" rendered="true" />
</td>
<TD>
<h:commandButton id="cancel_id" value="CANCEL" rendered="true" />
</TD>
</tr></table>
</p.>
<table>
<tr>
<td>
<h:outputText value="Law_ID:"/>
</td>
<td>
<h:inputText id="Law_id" />
</td>
</tr>
<tr>
<td>
<h:outputText value="Law_Description:"/>
</td>
<td>
<h:inputText id="Law_desc_id" />
</td>
</tr>
</table>
</h:form>
</body>
</f:view>
</html>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<f:view>
<!-- <f:loadBundle basename="com.fms.fins.web.Messages.Application" var="msgsApp" /> -->
<head>
<base href="<%=basePath%>">
<title>My JSF 'AddLaw.jsp' starting page</title>
</head>
<body>
<h:form>
<h:commandButton id="close_id" value="CLOSE" rendered="true" />
</h:form>
</body>
</f:view>
</html>

