Checkbox not sending value to database

I have a form I have built in dreamweaver cs4, the textfields work correctly sending the typed information to my mysql db. I need to add a lot of check boxes to the form for persons to pick from. I added a  couple and tested them and I always get a "N" value returned to the datbase even though the box has been check for yes. I added the check box like I did the text field, but i've noticed the recordset doesn't keep it's value when I go in and look at it. Could someone look at my script and see what I am doing wrong please? Still learning.
<?php require_once('../Connections/VendorRegistration.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;   
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  return $theValue;
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO Results (`date`, Name, Address, City, `State`, Zip, Contact, Phone, Fax, Email, Website, `AC Filters`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['date'], "text"),
                       GetSQLValueString($_POST['Name'], "text"),
                       GetSQLValueString($_POST['Address'], "text"),
                       GetSQLValueString($_POST['City'], "text"),
                       GetSQLValueString($_POST['State'], "text"),
                       GetSQLValueString($_POST['Zip'], "text"),
                       GetSQLValueString($_POST['Contact'], "text"),
                       GetSQLValueString($_POST['Phone'], "text"),
                       GetSQLValueString($_POST['Fax'], "text"),
                       GetSQLValueString($_POST['Email'], "text"),
                       GetSQLValueString($_POST['Website'], "text"),
                       GetSQLValueString(isset($_POST['AC Filters']) ? "true" : "", "defined","'Y'","'N'"));
  mysql_select_db($database_VendorRegistration, $VendorRegistration);
  $Result1 = mysql_query($insertSQL, $VendorRegistration) or die(mysql_error());
mysql_select_db($database_VendorRegistration, $VendorRegistration);
$query_Recordset2 = "SELECT * FROM Results";
$Recordset2 = mysql_query($query_Recordset2, $VendorRegistration) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
$query_Recordse2 = "SELECT * FROM Results";
$Recordse2 = mysql_query($query_Recordse2, $VendorRegistration) or die(mysql_error());
$row_Recordse2 = mysql_fetch_assoc($Recordse2);
$totalRows_Recordse2 = mysql_num_rows($Recordse2);
$query_Recordset2 = "SELECT * FROM Results";
$Recordset2 = mysql_query($query_Recordset2, $VendorRegistration) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
$query_Recordset2 = "SELECT * FROM Results";
$Recordset2 = mysql_query($query_Recordset2, $VendorRegistration) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
$query_Recordset2 = "SELECT * FROM Results";
$Recordset2 = mysql_query($query_Recordset2, $VendorRegistration) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
p.MsoNormal {
margin:0pt;
margin-bottom:.0001pt;
font-size:16pt;
font-family:"Times New Roman";
text-align: center;
body p {
font-family: Arial, Helvetica, sans-serif;
body p {
font-family: Arial, Helvetica, sans-serif;
body p {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
body p {
text-align: left;
Fontbody {
font-family: Arial, Helvetica, sans-serif;
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
#form1 table tr td {
text-align: center;
font-size: 16px;
#form1 table tr {
text-align: center;
#form1 table tr td table tr td table tr td {
text-align: left;
#form1 div table tr td div table {
text-align: left;
.right {
text-align: right;
#form1 div table tr td table {
font-size: 12px;
#form1 div table tr td table tr td div {
font-size: 12px;
-->
</style>
</head>
<body>
<form action="<?php echo $editFormAction; ?>" id="form1" name="form1" method="POST">
  <div align="left">
    <table width="1025" border="0" cellpadding="2" cellspacing="2">
      <td width="333"><div align="right">Date </div></td>
        <td width="336"><div align="left">
          <input type="text" name="date" id="date" size="30" />
        </div></td>
        <td width="339" colspan="2" rowspan="14"> </td>
        </tr>
      <tr>
        <td><div align="right">Vendor Name</div></td>
        <td><label> </label>
          <div align="left">
            <input name="Name" type="text" id="Name" size="50" />
        </div></td>
      </tr>
      <tr>
        <td><div align="right">Mailing Address</div></td>
        <td><div align="left">
          <label>
            <input name="Address" type="text" id="Address" size="50" />
            </label>
        </div></td>
      </tr>
      <tr>
        <td><div align="right">City</div></td>
        <td><label> </label>
          <div align="left">
            <input name="City" type="text" id="City" size="50" />
        </div></td>
      </tr>
      <tr>
        <td><div align="right">State</div></td>
        <td><div align="left">
          <input type="text" name="State" id="State" />
        </div></td>
      </tr>
      <tr>
        <td><div align="right">Zip</div></td>
        <td><div align="right">
          <label> </label>
          <div align="left">
            <input type="text" name="Zip" id="Zip" />
            </div>
        </div></td>
      </tr>
      <tr>
        <td><div align="right">Contact for Bids</div></td>
        <td><div align="right">
          <label> </label>
          <div align="left">
            <input name="Contact" type="text" id="Contact" size="30" />
            </div>
        </div></td>
      </tr>
      <tr>
        <td><div align="right">Phone</div></td>
        <td><div align="left">
          <input type="text" name="Phone" id="Phone" />
        </div></td>
      </tr>
      <tr>
        <td><div align="right">Email</div></td>
        <td><div align="right">
          <label> </label>
          <div align="left">
            <input type="text" name="Email" id="Email" />
            </div>
        </div></td>
      </tr>
      <tr>
        <td><div align="right">Fax</div></td>
        <td><div align="left">
          <input type="text" name="Fax" id="Fax" />
        </div></td>
      </tr>
      <tr>
        <td><div align="right">Website</div></td>
        <td><div align="left">
          <input type="text" name="Website" id="Website" />
        </div></td>
      </tr>
      <tr>
        <td><div align="right"><br />
          Please select if applicable to your company<br />
          <br />
        </div></td>
        <td><div align="right"></div></td>
      </tr>
      <tr>
        <td><div align="right">State of Texas CISV<br />
        (Catalog Information Systems Vendor)</div></td>
        <td><div align="right">
          <label> </label>
          <div align="left">
            <input type="radio" name="radio" id="yes" value="yes" />
            Yes</div>
        </div></td>
      </tr>
      <tr>
        <td><div align="right">HUB or MWBE</div>
        <td><div align="left">
            <input type="radio" name="RadioGroup1" value="HUB" id="RadioGroup1_0" />
            <label>HUB</label>
            </div>
          <label> </label>
          <div align="left">
            <input type="radio" name="RadioGroup1" value="MWBE" id="RadioGroup1_1" />
          MWBE</div>
        <div align="left"></div></td>
      </tr>
      <tr>
        <td colspan="3"><p align="left" class="MsoNormal"><br />
        </p></td>
      </tr>
      <tr>
        <td><label>
          <div align="right">AC Filters</div>
        </label></td>
        <td><p align="left" class="MsoNormal">
          <label>
            <div align="left">
            <input type="checkbox" name="AC Filters" id="AC Filters" />
        </label></td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td> </td>
        <td> </td>
           </tr>
      </tr>
      <tr>
        <td><label>
          <input type="submit" name="submit" id="submit" value="Submit" />
        </label></td>
        <td colspan="2"> </td>
      </tr>
    </table>
  </div>
  <input type="hidden" name="MM_insert" value="form1" />
</form>
</body>
</html>
<?php
mysql_free_result($Recordset2);
?>

This is your problem:
<input type="checkbox" name="AC Filters" id="AC Filters" />
You cannot use spaces in names or IDs. Replace the space with an underscore:
<input type="checkbox" name="AC_Filters" id="AC_Filters" />
You will also need to amend $_POST['AC Filters'] to $_POST['AC_Filters'].

Similar Messages

  • Retractor for Statistical Key Figures Not Sending Values

    I have configured the standard retractor for primary costs and stat key figures based on all the documentation.  Primary costs retract perfectly.  Stat Key Figures do not send over the values.
    I have configured UPBR_RETRACT with UPB_RET_STKEYFIG.  In the update rules the only thing I have changed is assigned ZRATENU to 0BPS_PRICE and 0QUANTITY to 0BPS_QUANTITY.  I copied the delivered planning level 4EXP0004 to a Z level assigned to my custom cube.  In UPBR_STRUCT I assigned to the correct structures /1SEM/_YS_CHAS_210ZEXP0004 and /1SEM/_YS_KYFS_210ZEXP0004.
    From BPS, when I run the retractor I get the message that "Retraction: Update completed without errors. Number of records:   56".  All of this tells me things are running fine.  My parameter group is setup as follows:
    Retr. R/3 Comp.          6
    Retractor Control          3
    Delta Update          0
    Destination          DE1CLNT209
    Test mode Is Active          0
    I go over to ECC and look at KP46.  The stat key figures by cost center have been transferred but the planned values all show 0.  When I go to table COSR, I see 0 in the planned fields. 
    Has anyone had this issue and do they know how to solve it?
    Thanks,
    Cherie

    Dear Chrie,
    Can u explain,  what are the keyfigures that are not getting retracted to R/3?
    If quantities and Unit of measure is not getting retracted, you will have to apply the note 889634. Check once.
    If you are using the function modules UPR_COST_PLAN_INIT and UPR_COST_PLAN_EXECUTE, then make sure that you pass only Object Currency (0AMOCCC) values to it, as it supports only those.
    Regards,
    Srinivas Kamireddy.

  • How to display checkbox that retrieve value from database?

    Hi,
    I have a problem, hope someone will help me.
    The problem is, I have 3 checkbox where contain different values.
    I will insert the values to db in array. When I retrieve the values, I got a problem to display it.
    Let say,my checkbox's value is:
    1.car
    2.bus
    3.lorry
    when I checked car and lorry, my array will be [car,bus] insert to db.
    For editing purpose, I need to display the checkbox again with the values from db. So, it should be :
    1.car (checked)
    2.bus (checked)
    3.lorry (unchecked)
    I can display the car and bus (checked) , but not the unchecked checkbox. Sometimes, it's repeating, car (checked) and car (unchecked) will display.
    Anybody have a suggestion?
    My codes:
    String[] list = {"car","bus","lorry"};
    String[] logtype ={"car","bus"}//retrieve from db (example)
    for (int i=0;i<logtype.length;i++){
    if (logtype.equals(list[i]){
    <input type="checkbox" name="type" value="<%=list[i]%>" checked>
    else{
    <input type="checkbox" name="type" value="<%=list[i]%>" >

    hey u can solve this problem by using vector instead of array
    here's the code
    <%
    Vector list=new Vector();
    list.addElement("car");
    list.addElement("bus");
    list.addElement("lorry");
    Vector logtype=new Vector();
    logtype.addElement("car");
    logtype.addElement("bus");
    for(int i=0;i<list.size();i++)
         if(logtype.contains(list.elementAt(i)))
         { %>
              <%=list.elementAt(i)%><input type="checkbox" name="type" value="<%=list.elementAt(i)%>" checked>
         <%}
         else
         {%>
              <%=list.elementAt(i)%><input type="checkbox" name="type" value="<%=list.elementAt(i)%>" >
         <%}
    %>

  • Error not send data a database of oracle please

    I cannot send data from a variable a the database of oracle.
    variables they are = unot,dost,trest but it does not recognize its values......
    it does not insert anything in the fields of the data base
    this code:
    con = DriverManager.getConnection(url,"ora1", "oracle");
    stmt = con.createStatement();
    String uprs = "insert into anexo (cod_ane,codigo,desc_anexo)
    values(" + unot + "," + dost + "," + trest +")";
    stmt.executeUpdate(uprs);
    this error:
    SQLException: ORA-00936: missing expression

    Are they text fields? Try surrounding them with quotes:
    String uprs = "insert into anexo (cod_ane,codigo,desc_anexo)
    values('" + unot + "','" + dost + "','" + trest +"')";Try displaying uprs before the executeUpdate() and make sure it's really valid SQL.

  • EJB 3.0 - JSF APPLICATION: DATA DOES NOT PERSIST TO THE DATABASE

    Hi,
    I am developing a JSF - EJB application and the data that I send from JSP Page through JSF Managed Bean --> Session Bean --> Java Persistence does not persist in database.
    Here is my scenario ( Iam using JDeveloper IDE to create this application) -
    SCENARIO START
    The scenario consists of two web pages, one enlisting all the users stored in the database, the other contains a form for adding a user
    1.) INDEX.JSP
    2.) ADDUSER.JSP
    Step 1: Create the USERS Table in database
    CREATE TABLE users
    user_id serial,
    username varchar(255) NOT NULL,
    first_name varchar(255),
    last_name varchar(255),
    password char(64) NOT NULL,
    CONSTRAINT pk_users PRIMARY KEY (user_id)
    Step 2: Add Database Connection To JDeveloper
    Go to Database Connection Navigator and create a New Database Connection using the Wizard
    Step 3: Create a New Application in JDeveloper and select JSF, EJB from Application Template
    Step 4: ENTITY BEAN - In the EJB Node Right Click and Select EJB à New Entites from Table (JPA/EJB3.0)
    Use The Wizard and create Entity Bean from Users Table which creates an Entity Bea POJO file as follows –
    User.java -
    package lux.domain;
    import java.io.Serializable;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.NamedQuery;
    import javax.persistence.SequenceGenerator;
    import javax.persistence.Table;
    @Entity
    @NamedQuery(name = "User.findAll", query = "select o from User o")
    @Table(name = "USERS")
    public class User implements Serializable {
    @Column(name="FIRST_NAME")
    private String firstName;
    @Column(name="LAST_NAME")
    private String lastName;
    @Column(nullable = false)
    private String password;
    @Column(nullable = false)
    private String username;
    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="users_seq_generator")
    @SequenceGenerator(name="users_seq_generator", sequenceName="users_user_id_seq")
    @Column(name="USER_ID", nullable = false)
    private Long userId;
    public User() {
    public String getFirstName() {
    return firstName;
    public void setFirstName(String firstName) {
    this.firstName = firstName;
    public String getLastName() {
    return lastName;
    public void setLastName(String lastName) {
    this.lastName = lastName;
    public String getPassword() {
    return password;
    public void setPassword(String password) {
    this.password = password;
    public String getUsername() {
    return username;
    public void setUsername(String username) {
    this.username = username;
    public Long getUserId() {
    return userId;
    public void setUserId(Long userId) {
    this.userId = userId;
    Step 5: STATELESS SESSION BEAN - In the EJB Node Right Click and Select EJB à New Entites from Table (JPA/EJB3.0)
    Again Right Click on Model and create Session Bean from Wizard which creates two files –
    UserDAOBean.java – Stateless Session Bean
    UserDAO.java – Local Interface
    package lux.facade;
    import java.security.MessageDigest;
    import java.security.NoSuchAlgorithmException;
    import java.util.List;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    import javax.persistence.Query;
    import lux.domain.User;
    @Stateless(name="UserDAO")
    public class UserDAOBean implements UserDAO {
    @PersistenceContext(unitName="Model")
    private EntityManager em;
    public UserDAOBean() {
    public User getUser(int UserId) {
    User u = new User();
    u = em.find(User.class, UserId);
    return u;
    public List<User> getAllUsers() {
    Query q = em.createQuery("SELECT u FROM User u");
    List<User> users = q.getResultList();
    return users;
    public void createUser(User u) {
    String hashedPw = hashPassword(u.getPassword());
    u.setPassword(hashedPw);
    em.persist(u);
    public void updateUser(User u) {
    String hashedPw = hashPassword(u.getPassword());
    u.setPassword(hashedPw);
    em.merge(u);
    public void deleteUser(User u) {
    em.remove(u);
    private String hashPassword(String password) {
    StringBuilder sb = new StringBuilder();
    try {
    MessageDigest messageDigest = MessageDigest.getInstance("SHA");
    byte[] bs;
    bs = messageDigest.digest(password.getBytes());
    for (int i = 0; i < bs.length; i++) {
    String hexVal = Integer.toHexString(0xFF & bs);
    if (hexVal.length() == 1) {
    sb.append("0");
    sb.append(hexVal);
    } catch (NoSuchAlgorithmException ex) {
    Logger.getLogger(UserDAOBean.class.getName()).log(Level.SEVERE, null, ex);
    return sb.toString();
    Step 6: Create a Deployment file in the Model and Deploy this to a JAR file
    Step 7: Now Right Click on View/Controller Node and create a Java File –
    UserController.java -
    package lux.controllers;
    import javax.ejb.EJB;
    import javax.faces.model.DataModel;
    import javax.faces.model.ListDataModel;
    import lux.domain.User;
    import lux.facade.UserDAO;
    public class UserController {
    @EJB UserDAO userDao;
    private User user;
    private DataModel model;
    public String createUser() {
    this.user = new User();
    return "create_new_user";
    public String saveUser() {
    String r = "success";
    try {
    userDao.createUser(user);
    } catch (Exception e) {
    e.printStackTrace();
    r = "failed";
    return r;
    public DataModel getUsers() {
    model = new ListDataModel(userDao.getAllUsers());
    return model;
    public User getUser() {
    return user;
    public void setUser(User user) {
    this.user = user;
    Step 8: Configure page flow in faces-config.xml
    1. Create the JSP file adduser.jsp by right-clicking View-Controller
    node and selecting New > JSP. Use the wizard to create JSF – JSP Page, fill in
    File Name adduser.jsp, click Finish. -
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>New user</title>
    </head>
    <body>
    <f:view>
    <h:form>
    <h:messages/>
    <h:panelGrid columns="2">
    <h:outputText value="Username"/>
    <h:inputText
    id="Username"
    value="#{user.user.username}"
    required="true"/>
    <h:outputText value="First name"/>
    <h:inputText
    id="FirstName"
    value="#{user.user.firstName}" />
    <h:outputText value="Last name"/>
    <h:inputText
    id="LastName"
    value="#{user.user.lastName}" />
    <h:outputText value="Password" />
    <h:inputSecret
    id="Password"
    value="#{user.user.password}"
    required="true" />
    <h:panelGroup/>
    <h:commandButton
    action="#{user.saveUser}"
    value="Save"/>
    </h:panelGrid>
    </h:form>
    </f:view>
    </body>
    </html>
    2. Repeat the previous step for another JSP file failed.jsp.
    3. On failed.jsp add the string
    Save failed
    Next we configure the page flow.
    1. Open faces-config.xml.
    2. Create index.jsp -
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>User Listing</title>
    </head>
    <body>
    <f:view>
    <h:form>
    <h:outputText value="User Listing"/>
    <h:commandLink action="#{user.createUser}" value="Create a user"/>
    <h:dataTable value="#{user.user}"
    var="dataTableItem" border="1" cellpadding="2" cellspacing="2">
    <h:column>
    <f:facet name="header">
    <h:outputText value="Username"/>
    </f:facet>
    <h:outputText value="#{dataTableItem.username}" />
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="First name"/>
    </f:facet>
    <h:outputText value="#{dataTableItem.firstName}" />
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="Last name"/>
    </f:facet>
    <h:outputText value="#{dataTableItem.lastName}" />
    </h:column>
    </h:dataTable>
    </h:form>
    </f:view>
    </body>
    </html>
    3. Drag an arrow from index.jsp to adduser.jsp and replace the arrow’s label to create_new_user.
    4. Repeat the previous step for failed, by dragging and arrow from adduser.jsp to failed.jsp renaming the label to f
    ailed
    5. Finally repeat the step for adduser.jsp, by dragging from adduser.jsp to index.jsp renaming the label to success.
    This creates the following faces-config.xml file –
    <?xml version='1.0' encoding='UTF-8'?>
    <faces-config>
    <managed-bean>
    <managed-bean-name>user</managed-bean-name>
    <managed-bean-class>lux.controllers.UserController</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    <managed-property>
    <property-name>username</property-name>
    <value>#{username}</value>
    </managed-property>
    <managed-property>
    <property-name>firstName</property-name>
    <value>#{firstName}</value>
    </managed-property>
    <managed-property>
    <property-name>lastName</property-name>
    <value>#{lastName}</value>
    </managed-property>
    <managed-property>
    <property-name>password</property-name>
    <value>#{password}</value>
    </managed-property>
    </managed-bean>
    <navigation-rule>
    <from-view-id>/index.jsp</from-view-id>
    <navigation-case>
    <from-outcome>create_new_user</from-outcome>
    <to-view-id>/adduser.jsp</to-view-id>
    </navigation-case>
    </navigation-rule>
    <navigation-rule>
    <from-view-id>/adduser.jsp</from-view-id>
    <navigation-case>
    <from-outcome>failed</from-outcome>
    <to-view-id>/failed.jsp</to-view-id>
    </navigation-case>
    <navigation-case>
    <from-outcome>success</from-outcome>
    <to-view-id>/index.jsp</to-view-id>
    </navigation-case>
    </navigation-rule>
    </faces-config>
    Step 9: Create a Deployment file in the View-Controller and Deploy this to a WAR file
    Step 10: Create a Deployment file in the View-Controller and create an EAR file and add Model’s JAR and View-Controller’s
    WAR files to it.
    Step 11: Run the JSP Files
    SCENARIO END
    Now, When I execute Index.jsp, it does not list values from database and when I click on Create User link, it takes me to adduser.jsp page. When I fill values in this page and click Save button, it takes me to Save Failed page and data does not persist to the database.
    WHAT IS WRONG OUT HERE ???

    If you set a breakpoint in your createUser method - does this code get executed?
    We have a couple of tutorials that might show you how to do this.
    EJB/JSF with ADF-binding tutorial:
    http://www.oracle.com/technology/obe/obe1013jdev/10131/ejb_and_jpa/master-detail_pagewith_ejb.htm
    EJB/JSF without ADF binding:
    http://www.oracle.com/technology/obe/JavaEE_tutorial_10131/index.htm

  • JSF - EJB 3.0 Application - Data does not persist to the database

    Hi,
    I am developing a JSF - EJB application and the data that I send from JSP Page through JSF Managed Bean --> Session Bean --> Java Persistence does not persist in database.
    Here is my scenario ( Iam using JDeveloper IDE to create this application) -
    ------------------------------------------------------- SCENARIO START
    The scenario consists of two web pages, one enlisting all the users stored in the database, the other contains a form for adding a user
    1.) INDEX.JSP
    2.) ADDUSER.JSP
    Step 1: Create the USERS Table in database
    CREATE TABLE users
    user_id serial,
    username varchar(255) NOT NULL,
    first_name varchar(255),
    last_name varchar(255),
    password char(64) NOT NULL,
    CONSTRAINT pk_users PRIMARY KEY (user_id)
    Step 2: Add Database Connection To JDeveloper
    Go to Database Connection Navigator and create a New Database Connection using the Wizard
    Step 3: Create a New Application in JDeveloper and select JSF, EJB from Application Template
    Step 4: ENTITY BEAN - In the EJB Node Right Click and Select EJB � New Entites from Table (JPA/EJB3.0)
    Use The Wizard and create Entity Bean from Users Table which creates an Entity Bea POJO file as follows �
    User.java -
    package lux.domain;
    import java.io.Serializable;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.NamedQuery;
    import javax.persistence.SequenceGenerator;
    import javax.persistence.Table;
    @Entity
    @NamedQuery(name = "User.findAll", query = "select o from User o")
    @Table(name = "USERS")
    public class User implements Serializable {
    @Column(name="FIRST_NAME")
    private String firstName;
    @Column(name="LAST_NAME")
    private String lastName;
    @Column(nullable = false)
    private String password;
    @Column(nullable = false)
    private String username;
    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="users_seq_generator")
    @SequenceGenerator(name="users_seq_generator", sequenceName="users_user_id_seq")
    @Column(name="USER_ID", nullable = false)
    private Long userId;
    public User() {
    public String getFirstName() {
    return firstName;
    public void setFirstName(String firstName) {
    this.firstName = firstName;
    public String getLastName() {
    return lastName;
    public void setLastName(String lastName) {
    this.lastName = lastName;
    public String getPassword() {
    return password;
    public void setPassword(String password) {
    this.password = password;
    public String getUsername() {
    return username;
    public void setUsername(String username) {
    this.username = username;
    public Long getUserId() {
    return userId;
    public void setUserId(Long userId) {
    this.userId = userId;
    Step 5: STATELESS SESSION BEAN - In the EJB Node Right Click and Select EJB � New Entites from Table (JPA/EJB3.0)
    Again Right Click on Model and create Session Bean from Wizard which creates two files �
    UserDAOBean.java � Stateless Session Bean
    UserDAO.java � Local Interface
    package lux.facade;
    import java.security.MessageDigest;
    import java.security.NoSuchAlgorithmException;
    import java.util.List;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    import javax.persistence.Query;
    import lux.domain.User;
    @Stateless(name="UserDAO")
    public class UserDAOBean implements UserDAO {
    @PersistenceContext(unitName="Model")
    private EntityManager em;
    public UserDAOBean() {
    public User getUser(int UserId) {
    User u = new User();
    u = em.find(User.class, UserId);
    return u;
    public List<User> getAllUsers() {
    Query q = em.createQuery("SELECT u FROM User u");
    List<User> users = q.getResultList();
    return users;
    public void createUser(User u) {
    String hashedPw = hashPassword(u.getPassword());
    u.setPassword(hashedPw);
    em.persist(u);
    public void updateUser(User u) {
    String hashedPw = hashPassword(u.getPassword());
    u.setPassword(hashedPw);
    em.merge(u);
    public void deleteUser(User u) {
    em.remove(u);
    private String hashPassword(String password) {
    StringBuilder sb = new StringBuilder();
    try {
    MessageDigest messageDigest = MessageDigest.getInstance("SHA");
    byte[] bs;
    bs = messageDigest.digest(password.getBytes());
    for (int i = 0; i < bs.length; i++) {
    String hexVal = Integer.toHexString(0xFF & bs);
    if (hexVal.length() == 1) {
    sb.append("0");
    sb.append(hexVal);
    } catch (NoSuchAlgorithmException ex) {
    Logger.getLogger(UserDAOBean.class.getName()).log(Level.SEVERE, null, ex);
    return sb.toString();
    Step 6: Create a Deployment file in the Model and Deploy this to a JAR file
    Step 7: Now Right Click on View/Controller Node and create a Java File �
    UserController.java -
    package lux.controllers;
    import javax.ejb.EJB;
    import javax.faces.model.DataModel;
    import javax.faces.model.ListDataModel;
    import lux.domain.User;
    import lux.facade.UserDAO;
    public class UserController {
    @EJB UserDAO userDao;
    private User user;
    private DataModel model;
    public String createUser() {
    this.user = new User();
    return "create_new_user";
    public String saveUser() {
    String r = "success";
    try {
    userDao.createUser(user);
    } catch (Exception e) {
    e.printStackTrace();
    r = "failed";
    return r;
    public DataModel getUsers() {
    model = new ListDataModel(userDao.getAllUsers());
    return model;
    public User getUser() {
    return user;
    public void setUser(User user) {
    this.user = user;
    Step 8: Configure page flow in faces-config.xml
    1. Create the JSP file adduser.jsp by right-clicking View-Controller
    node and selecting New > JSP. Use the wizard to create JSF � JSP Page, fill in
    File Name adduser.jsp, click Finish. -
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>New user</title>
    </head>
    <body>
    <f:view>
    <h:form>
    <h:messages/>
    <h:panelGrid columns="2">
    <h:outputText value="Username"/>
    <h:inputText
    id="Username"
    value="#{user.user.username}"
    required="true"/>
    <h:outputText value="First name"/>
    <h:inputText
    id="FirstName"
    value="#{user.user.firstName}" />
    <h:outputText value="Last name"/>
    <h:inputText
    id="LastName"
    value="#{user.user.lastName}" />
    <h:outputText value="Password" />
    <h:inputSecret
    id="Password"
    value="#{user.user.password}"
    required="true" />
    <h:panelGroup/>
    <h:commandButton
    action="#{user.saveUser}"
    value="Save"/>
    </h:panelGrid>
    </h:form>
    </f:view>
    </body>
    </html>
    2. Repeat the previous step for another JSP file failed.jsp.
    3. On failed.jsp add the string <h2>Save failed</h2>.
    Next we configure the page flow.
    1. Open faces-config.xml.
    2. Create index.jsp -
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>User Listing</title>
    </head>
    <body>
    <f:view>
    <h:form>
    <h1><h:outputText value="User Listing"/></h1>
    <p><h:commandLink action="#{user.createUser}" value="Create a user"/></p>
    <h:dataTable value="#{user.user}"
    var="dataTableItem" border="1" cellpadding="2" cellspacing="2">
    <h:column>
    <f:facet name="header">
    <h:outputText value="Username"/>
    </f:facet>
    <h:outputText value="#{dataTableItem.username}" />
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="First name"/>
    </f:facet>
    <h:outputText value="#{dataTableItem.firstName}" />
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="Last name"/>
    </f:facet>
    <h:outputText value="#{dataTableItem.lastName}" />
    </h:column>
    </h:dataTable>
    </h:form>
    </f:view>
    </body>
    </html>
    3. Drag an arrow from index.jsp to adduser.jsp and replace the arrow�s label to create_new_user.
    4. Repeat the previous step for failed, by dragging and arrow from adduser.jsp to failed.jsp renaming the label to f
    ailed
    5. Finally repeat the step for adduser.jsp, by dragging from adduser.jsp to index.jsp renaming the label to success.
    This creates the following faces-config.xml file �
    <?xml version='1.0' encoding='UTF-8'?>
    <faces-config>
    <managed-bean>
    <managed-bean-name>user</managed-bean-name>
    <managed-bean-class>lux.controllers.UserController</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    <managed-property>
    <property-name>username</property-name>
    <value>#{username}</value>
    </managed-property>
    <managed-property>
    <property-name>firstName</property-name>
    <value>#{firstName}</value>
    </managed-property>
    <managed-property>
    <property-name>lastName</property-name>
    <value>#{lastName}</value>
    </managed-property>
    <managed-property>
    <property-name>password</property-name>
    <value>#{password}</value>
    </managed-property>
    </managed-bean>
    <navigation-rule>
    <from-view-id>/index.jsp</from-view-id>
    <navigation-case>
    <from-outcome>create_new_user</from-outcome>
    <to-view-id>/adduser.jsp</to-view-id>
    </navigation-case>
    </navigation-rule>
    <navigation-rule>
    <from-view-id>/adduser.jsp</from-view-id>
    <navigation-case>
    <from-outcome>failed</from-outcome>
    <to-view-id>/failed.jsp</to-view-id>
    </navigation-case>
    <navigation-case>
    <from-outcome>success</from-outcome>
    <to-view-id>/index.jsp</to-view-id>
    </navigation-case>
    </navigation-rule>
    </faces-config>
    Step 9: Create a Deployment file in the View-Controller and Deploy this to a WAR file
    Step 10: Create a Deployment file in the View-Controller and create an EAR file and add Model�s JAR and View-Controller�s
    WAR files to it.
    Step 11: Run the JSP Files
    ------------------------------------------------------- SCENARIO END
    Now, When I execute Index.jsp, it does not list values from database and when I click on Create User link, it takes me to adduser.jsp page. When I fill values in this page and click Save button, it takes me to Save Failed page and data does not persist to the database.
    WHAT IS WRONG OUT HERE ???

    PLZZZZZZZZZzzzzzzzzzzz HELP ! ! !

  • EJB-JSF Application : Data does not persist to the database

    Hi,
    I am developing a JSF - EJB application and the data that I send from JSP Page through JSF Managed Bean --> Session Bean --> Java Persistence does not persist in database.
    Here is my scenario ( Iam using JDeveloper IDE to create this application) -
    SCENARIO START
    The scenario consists of two web pages, one enlisting all the users stored in the database, the other contains a form for adding a user
    1.) INDEX.JSP
    2.) ADDUSER.JSP
    Step 1: Create the USERS Table in database
    CREATE TABLE users
    user_id serial,
    username varchar(255) NOT NULL,
    first_name varchar(255),
    last_name varchar(255),
    password char(64) NOT NULL,
    CONSTRAINT pk_users PRIMARY KEY (user_id)
    Step 2: Add Database Connection To JDeveloper
    Go to Database Connection Navigator and create a New Database Connection using the Wizard
    Step 3: Create a New Application in JDeveloper and select JSF, EJB from Application Template
    Step 4: ENTITY BEAN - In the EJB Node Right Click and Select EJB � New Entites from Table (JPA/EJB3.0)
    Use The Wizard and create Entity Bean from Users Table which creates an Entity Bea POJO file as follows �
    User.java -
    package lux.domain;
    import java.io.Serializable;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.NamedQuery;
    import javax.persistence.SequenceGenerator;
    import javax.persistence.Table;
    @Entity
    @NamedQuery(name = "User.findAll", query = "select o from User o")
    @Table(name = "USERS")
    public class User implements Serializable {
    @Column(name="FIRST_NAME")
    private String firstName;
    @Column(name="LAST_NAME")
    private String lastName;
    @Column(nullable = false)
    private String password;
    @Column(nullable = false)
    private String username;
    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="users_seq_generator")
    @SequenceGenerator(name="users_seq_generator", sequenceName="users_user_id_seq")
    @Column(name="USER_ID", nullable = false)
    private Long userId;
    public User() {
    public String getFirstName() {
    return firstName;
    public void setFirstName(String firstName) {
    this.firstName = firstName;
    public String getLastName() {
    return lastName;
    public void setLastName(String lastName) {
    this.lastName = lastName;
    public String getPassword() {
    return password;
    public void setPassword(String password) {
    this.password = password;
    public String getUsername() {
    return username;
    public void setUsername(String username) {
    this.username = username;
    public Long getUserId() {
    return userId;
    public void setUserId(Long userId) {
    this.userId = userId;
    Step 5: STATELESS SESSION BEAN - In the EJB Node Right Click and Select EJB � New Entites from Table (JPA/EJB3.0)
    Again Right Click on Model and create Session Bean from Wizard which creates two files �
    UserDAOBean.java � Stateless Session Bean
    UserDAO.java � Local Interface
    package lux.facade;
    import java.security.MessageDigest;
    import java.security.NoSuchAlgorithmException;
    import java.util.List;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    import javax.persistence.Query;
    import lux.domain.User;
    @Stateless(name="UserDAO")
    public class UserDAOBean implements UserDAO {
    @PersistenceContext(unitName="Model")
    private EntityManager em;
    public UserDAOBean() {
    public User getUser(int UserId) {
    User u = new User();
    u = em.find(User.class, UserId);
    return u;
    public List<User> getAllUsers() {
    Query q = em.createQuery("SELECT u FROM User u");
    List<User> users = q.getResultList();
    return users;
    public void createUser(User u) {
    String hashedPw = hashPassword(u.getPassword());
    u.setPassword(hashedPw);
    em.persist(u);
    public void updateUser(User u) {
    String hashedPw = hashPassword(u.getPassword());
    u.setPassword(hashedPw);
    em.merge(u);
    public void deleteUser(User u) {
    em.remove(u);
    private String hashPassword(String password) {
    StringBuilder sb = new StringBuilder();
    try {
    MessageDigest messageDigest = MessageDigest.getInstance("SHA");
    byte[] bs;
    bs = messageDigest.digest(password.getBytes());
    for (int i = 0; i < bs.length; i++) {
    String hexVal = Integer.toHexString(0xFF & bs);
    if (hexVal.length() == 1) {
    sb.append("0");
    sb.append(hexVal);
    } catch (NoSuchAlgorithmException ex) {
    Logger.getLogger(UserDAOBean.class.getName()).log(Level.SEVERE, null, ex);
    return sb.toString();
    Step 6: Create a Deployment file in the Model and Deploy this to a JAR file
    Step 7: Now Right Click on View/Controller Node and create a Java File �
    UserController.java -
    package lux.controllers;
    import javax.ejb.EJB;
    import javax.faces.model.DataModel;
    import javax.faces.model.ListDataModel;
    import lux.domain.User;
    import lux.facade.UserDAO;
    public class UserController {
    @EJB UserDAO userDao;
    private User user;
    private DataModel model;
    public String createUser() {
    this.user = new User();
    return "create_new_user";
    public String saveUser() {
    String r = "success";
    try {
    userDao.createUser(user);
    } catch (Exception e) {
    e.printStackTrace();
    r = "failed";
    return r;
    public DataModel getUsers() {
    model = new ListDataModel(userDao.getAllUsers());
    return model;
    public User getUser() {
    return user;
    public void setUser(User user) {
    this.user = user;
    Step 8: Configure page flow in faces-config.xml
    1. Create the JSP file adduser.jsp by right-clicking View-Controller
    node and selecting New > JSP. Use the wizard to create JSF � JSP Page, fill in
    File Name adduser.jsp, click Finish. -
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>New user</title>
    </head>
    <body>
    <f:view>
    <h:form>
    <h:messages/>
    <h:panelGrid columns="2">
    <h:outputText value="Username"/>
    <h:inputText
    id="Username"
    value="#{user.user.username}"
    required="true"/>
    <h:outputText value="First name"/>
    <h:inputText
    id="FirstName"
    value="#{user.user.firstName}" />
    <h:outputText value="Last name"/>
    <h:inputText
    id="LastName"
    value="#{user.user.lastName}" />
    <h:outputText value="Password" />
    <h:inputSecret
    id="Password"
    value="#{user.user.password}"
    required="true" />
    <h:panelGroup/>
    <h:commandButton
    action="#{user.saveUser}"
    value="Save"/>
    </h:panelGrid>
    </h:form>
    </f:view>
    </body>
    </html>
    2. Repeat the previous step for another JSP file failed.jsp.
    3. On failed.jsp add the string
    Save failed
    Next we configure the page flow.
    1. Open faces-config.xml.
    2. Create index.jsp -
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>User Listing</title>
    </head>
    <body>
    <f:view>
    <h:form>
    <h:outputText value="User Listing"/>
    <h:commandLink action="#{user.createUser}" value="Create a user"/>
    <h:dataTable value="#{user.user}"
    var="dataTableItem" border="1" cellpadding="2" cellspacing="2">
    <h:column>
    <f:facet name="header">
    <h:outputText value="Username"/>
    </f:facet>
    <h:outputText value="#{dataTableItem.username}" />
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="First name"/>
    </f:facet>
    <h:outputText value="#{dataTableItem.firstName}" />
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="Last name"/>
    </f:facet>
    <h:outputText value="#{dataTableItem.lastName}" />
    </h:column>
    </h:dataTable>
    </h:form>
    </f:view>
    </body>
    </html>
    3. Drag an arrow from index.jsp to adduser.jsp and replace the arrow�s label to create_new_user.
    4. Repeat the previous step for failed, by dragging and arrow from adduser.jsp to failed.jsp renaming the label to f
    ailed
    5. Finally repeat the step for adduser.jsp, by dragging from adduser.jsp to index.jsp renaming the label to success.
    This creates the following faces-config.xml file �
    <?xml version='1.0' encoding='UTF-8'?>
    <faces-config>
    <managed-bean>
    <managed-bean-name>user</managed-bean-name>
    <managed-bean-class>lux.controllers.UserController</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    <managed-property>
    <property-name>username</property-name>
    <value>#{username}</value>
    </managed-property>
    <managed-property>
    <property-name>firstName</property-name>
    <value>#{firstName}</value>
    </managed-property>
    <managed-property>
    <property-name>lastName</property-name>
    <value>#{lastName}</value>
    </managed-property>
    <managed-property>
    <property-name>password</property-name>
    <value>#{password}</value>
    </managed-property>
    </managed-bean>
    <navigation-rule>
    <from-view-id>/index.jsp</from-view-id>
    <navigation-case>
    <from-outcome>create_new_user</from-outcome>
    <to-view-id>/adduser.jsp</to-view-id>
    </navigation-case>
    </navigation-rule>
    <navigation-rule>
    <from-view-id>/adduser.jsp</from-view-id>
    <navigation-case>
    <from-outcome>failed</from-outcome>
    <to-view-id>/failed.jsp</to-view-id>
    </navigation-case>
    <navigation-case>
    <from-outcome>success</from-outcome>
    <to-view-id>/index.jsp</to-view-id>
    </navigation-case>
    </navigation-rule>
    </faces-config>
    Step 9: Create a Deployment file in the View-Controller and Deploy this to a WAR file
    Step 10: Create a Deployment file in the View-Controller and create an EAR file and add Model�s JAR and View-Controller�s
    WAR files to it.
    Step 11: Run the JSP Files
    SCENARIO END
    Now, When I execute Index.jsp, it does not list values from database and when I click on Create User link, it takes me to adduser.jsp page. When I fill values in this page and click Save button, it takes me to Save Failed page and data does not persist to the database.
    WHAT IS WRONG OUT HERE ???

    If you set a breakpoint in your createUser method - does this code get executed?
    We have a couple of tutorials that might show you how to do this.
    EJB/JSF with ADF-binding tutorial:
    http://www.oracle.com/technology/obe/obe1013jdev/10131/ejb_and_jpa/master-detail_pagewith_ejb.htm
    EJB/JSF without ADF binding:
    http://www.oracle.com/technology/obe/JavaEE_tutorial_10131/index.htm

  • Send Email and automatically save new value into database

    Hi,
    I think this is a very unique problem, hope that anyone could help me. I tried to send email notification using pl/sql block (check_delay) as below. Please focus to this section first, from the pl/sql:
    Problem 1
    --> if emp_rec.OVERDUE_AMOUNT_PAID is not null then
    dbms_output.put_line('emp_rec.payment_progress_id ' || emp_rec.payment_progress_id || crlf);
    select c.PAYMENT_PROGRESS into payment_progress from credit_sales c where c.PAYMENT_PROGRESS_ID = emp_rec.payment_progress_id;
    payment_ratio := (payment_progress/emp_rec.invoice_amount);
    dbms_output.put_line('count ratio progress payment to invoice amount ' || payment_ratio || crlf);
    dbms_output.put_line('payment progress ' || payment_progress || crlf);
    Here, sql checks whether overdue amount is being paid in progress from payment_overdue table..then creates variables for ratio(payment_ratio) and progress payment amount(payment_progress). After that if payment_ratio < 0.1 it must sends email notification to customer_id and customer_representative_id. However, it does NOT send notification to
    customer_id! How do I amend the code so that customer_id will get the notification too?
    Problem 2
    In problem 2, please focus to :
    -->if emp_rec.OVERDUE_AMOUNT_PAID is null then
    If customer does not pay any amount, sql will first checks whether delay between scheduled payment date and current system is more than 3 days..
    dbms_output.put_line('count days delay ' || round(sysdate - to_date(emp_rec.scheduled_payment_date)) || crlf || crlf);
    if round(sysdate - to_date(emp_rec.scheduled_payment_date)) >3 then
    After that, sql will counts how many times customer delays. If first time, the notification will count notification as number 1..and update remark column with the message and count value as below..
    select count(a.payment_overdue_id) as count into count from payment_overdue a where a.customer_id = emp_rec.CUSTOMER_ID and a.invoice_no = emp_rec.invoice_no;
         dbms_output.put_line('update remark : '||emp_rec.remark);
    update PAYMENT_OVERDUE set remark='Reminder notice no '||count where payment_overdue_id=emp_rec.payment_overdue_id;
    Finally, notification to be sent to customer with the message format as below..
    email_to:=emp_rec.customer_id||default_email;
    select b.INVOICE_NO into invoice_no from INVOICE b where b.INVOICE_ID = emp_rec.INVOICE_ID;
    subj:='Reminder to make payment for Invoice No '||invoice_no;
    mesg:='Kindly make payment for your amount outstanding as per Invoice No '||invoice_no||'. Reminder notice no '||count;
    dbms_output.put_line('Sending email to ' || email_to || ' subject: ' || subj);
    e_mail_message(email_to,email_to,subj,mesg);
    Unfortunately, no email notification being sent to customer with this message format.. Please help me to make customer to receive the notification with this format.
    Kindly, thank you so much for you guys to help me solve these two problems, Problem 1 and Problem 2....
    Thank you.
    CREATE OR REPLACE PROCEDURE TEST.check_delay AS
    NO binary_float;
    CURSOR emp_cur is
    select * from PAYMENT_OVERDUE where FLAG=3 and STATUS='OUTSTANDING';
    emp_rec emp_cur%rowtype;
    email_to varchar2(200);
    default_email varchar2(200);
    mesg varchar2(4000);
    invoice_no varchar2(100);
    subj varchar2(4000);
    payment_progress binary_float;
    payment_ratio binary_float;
    count number;
    crlf VARCHAR2( 2 ):= CHR( 13 ) || CHR( 10 );
    BEGIN
    default_email:='@test.com';
    FOR emp_rec in emp_cur
    LOOP
    if emp_rec.OVERDUE_AMOUNT_PAID is null then
    dbms_output.put_line('count days delay ' || round(sysdate - to_date(emp_rec.scheduled_payment_date)) || crlf || crlf);
    if round(sysdate - to_date(emp_rec.scheduled_payment_date)) >3 then
         select count(a.payment_overdue_id) as count into count from payment_overdue a where a.customer_id = emp_rec.CUSTOMER_ID and a.invoice_no = emp_rec.invoice_no;
         dbms_output.put_line('update remark : '||emp_rec.remark);
    update PAYMENT_OVERDUE set remark='Reminder notice no '||count where payment_overdue_id=emp_rec.payment_overdue_id;
         email_to:=emp_rec.customer_id||default_email;
    select b.INVOICE_NO into invoice_no from INVOICE b where b.INVOICE_ID = emp_rec.INVOICE_ID;
    subj:='Reminder to make payment for Invoice No '||invoice_no;
    mesg:='Kindly make payment for your amount outstanding as per Invoice No '||invoice_no||'. Reminder notive no '||count;
    dbms_output.put_line('Sending email to ' || email_to || ' subject: ' || subj);
    e_mail_message(email_to,email_to,subj,mesg);
    end if;
    end if;
    if emp_rec.OVERDUE_AMOUNT_PAID is not null then
    dbms_output.put_line('emp_rec.payment_progress_id ' || emp_rec.payment_progress_id || crlf);
    select c.PAYMENT_PROGRESS into payment_progress from credit_sales c where c.PAYMENT_PROGRESS_ID = emp_rec.payment_progress_id;
    payment_ratio := (payment_progress/emp_rec.invoice_amount);
    dbms_output.put_line('count ratio progress payment to invoice amount ' || payment_ratio || crlf);
    dbms_output.put_line('payment progress ' || payment_progress || crlf);
    if payment_ratio < 0.1 then
    email_to:=emp_rec.customer_id||default_email;
    select b.INVOICE_NO into invoice_no from INVOICE b where b.INVOICE_ID = emp_rec.INVOICE_ID;
    subj:='Reminder to settle outstanding amount for Invoice No '||invoice_no;
    mesg:='Kindly settle your outstanding payment as per Invoice No '||invoice_no;
    dbms_output.put_line('Sending email to ' || email_to || ' subject: ' || subj);
    e_mail_message(email_to,email_to,subj,mesg);
    email_to:=emp_rec.customer_representative_id||default_email;
    subj:='Reminder to settle outstanding amount for Invoice No '||invoice_no;
    mesg:='Kindly settle your outstanding payment as per Invoice No '||invoice_no;
    dbms_output.put_line('Sending email to ' || email_to || ' subject: ' || subj);
    e_mail_message(email_to,email_to,subj,mesg);
    end if;
    if (payment_ratio < 0.5 && payment_ratio > 0.1) then
    select b.INVOICE_NO into invoice_no from INVOICE b where b.INVOICE_ID = emp_rec.INVOICE_ID;
         email_to:=emp_rec.customer_id||default_email;
    subj:='Reminder to settle outstanding amount for Invoice No '||invoice_no;
    mesg:='Kindly settle your outstanding payment as per Invoice No '||invoice_no;
    dbms_output.put_line('Sending email to ' || email_to || ' subject: ' || subj);
    e_mail_message(email_to,email_to,subj,mesg);
    end if;
    end if;
    END LOOP;
    END;
    /

    Hi BownieCross;
    If you are using a local database file in your project the following may be the cause.
    From Microsoft Documentation:
    Issue:
    "Every time I test my application and modify data, my changes are gone the next time I run my application."
    Explanation:
    The value of the Copy
    to Output Directory property is Copy
    if newer or Copy
    always. The database in your output folder (the database that’s being modified when you test your application) is overwritten every
    time that you build your project. For more information, see How
    to: Manage Local Data Files in Your Project.
    Fernando (MCSD)
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects
    and unknown namespaces.

  • SelectOneChoice not showing all values from database

    Hi!
    I have to put a list of values in my select one choice. When I do the query in database, all the values are selected. But, with the same query on JPQL, the select on choice do not show all values in database. Anyone can help me, please?
    P.S.: I am using SelectOneChoice with SelectItems, in JDeveloper 11g
    Code:
    <af:selectOneChoice id="selAction" value="#{row.idCmd}"
    unselectedLabel="&lt;Selecione>">
    <af:forEach var="alertTypeNode"
    items="#{bindings.actionFindAll.iteratorBinding.allRowsInRange}">
    <af:selectItem value="#{alertTypeNode.dataProvider.idCmd}"
    label="#{alertTypeNode.dataProvider.nmCmd}"
    id="si1"/>
    </af:forEach>
    </af:selectOneChoice>

    In your page binding check the rangesize setting for the executable you use - set it to -1.

  • Notify Operator Task not sending email, Database mail works fine, Added Profile to Agent

    SQL Server 2008 R2, Latest Updates. 
    I added a Service Broker that has Alerts and Notifications in it.  In adding the service broker I had to go into the Agent Properties, Alert System, enable mail Profile, enabled the failsafe operator, etc. 
    I get email Alerts from the Service Broker that I Installed. I get the test emails too.  On the Properties of the Agent Job, I can get an email of the Completion, success or failure of the Job itself. 
    If I create a Maintenance Plan, that all that is in it a a Notify Operator Task, set it up with the same users, I never get the emails. If I go into the Reporting and Logging an then sent a email of the Log of the Job, I get that just fine too.
    Microsoft(R) Server Maintenance Utility (Unicode) Version 10.50.2500
    Report was generated on "SQL".
    Maintenance Plan: TestEmail
    Duration: 00:00:00
    Status: Succeeded.
    Details:
    F Notify Operator - Success (SQL)
    Task start: 2014-06-02T08:45:07.
    Task end: 2014-06-02T08:45:07.
    Success
    This started AFTER I enable the Alert System, Enable Mail Profile. 
    The server has been rebooted a few times since this started happening, so its not because I have not restarted the Agent. 
    If I uncheck the Enable Mail Profile in the Agent Alert System, I still get the Job's Log, but not the email of the Completion, Success or Failure. 

    Hello,
    Currently, I cannot reproduce the issue on my test environment. It works well when I create a maintenance plan include the Notify Operator task. This task uses the sp_notify_operator stored procedure. Did you check the T-SQL statements
    of the task ? You can get the statements by check the "View T-SQL" on the
    Notify Operators Task dialog.
    Please refer to the following statement of using sp_notify_operator:
    EXEC dbo.sp_notify_operator
    @profile_name = N'profile_name', --If profilename is not specified, the default Database Mail profile is used.
    @name = N'operator_name',
    @subject = N'Test Notification',
    @body = N'This is a test of notification.' ;
    GO
    Regards,
    Fanny Liu
    If you have any feedback on our support, please click here. 
    Fanny Liu
    TechNet Community Support

  • Mailbox recipient does not have a mailbox database

    For one of our customers we are currently working on a prove of concept to implement on premise exchange servers. The problem mentioned below takes place on test servers.
    Server names and mail domain names are changed to generic values.
    On our on premise exchange environment we encounter the following problems when emailing to a specific email domain .
    Email to the domain companyname.com is placed in to the Unreachable Domain queue with the following error:
    Last Error: The mailbox recipient does not have a mailbox database
    Queue ID: SERVEREX01\Unreachable
    Recipients:  [email protected];2;3;The mailbox recipient does not have a mailbox database;1;<No Home Database>
    Situation:
    Customer uses a local Active Directory which contains all the user accounts and uses Office 365 / Exchange Online to provide these users with a mailbox. SSO between the local AD and O365 is provided by a third party identity provider.
     Dirsync is used to sync all user information from the local AD to O365 AD. This also includes the SMTP addresses users have on the Office 365 mailbox. In the local AD this information is saved is the proxyaddress attribute field and synced
    to O365. Office 365 uses the following mail domains for customer: companyname.com and companyname.onmicrosoft.com.
    Customer wants to use local on premise exchange servers for specific locations and users and doesn’t want to implement a hybrid exchange environment. Therefore we installed an Exchange 2010 Edge server in the DMZ and an Exchange 2013 MBX
    / CAS server in the server network. The Exchange 2013 server is installed in the same Active Directory as the one mentioned above. This environment uses the mail domain @central.companyname.com. The email environment is configured to only accept email for
    this domain.
    The email environment works fine. It can send and receive email internally and externally. There is only one issue. It’s impossible to send email from the on premise environment to office 365. The other way around (O365 to on premise)
    works fine.
    When an email is send to a companyname.com email address the exchange 2013 mail server places the email in the Unreachable Domain queue and reports 
    the following error:
    Last Error: The mailbox recipient does not have a mailbox database
    Queue ID: SERVEREX01\Unreachable
    Recipients:  [email protected];2;3;The mailbox recipient does not have a mailbox database;1;<No Home Database>
    This is caused by the fact that the @companyname.com email addresses are stored in the active directory exchange uses. We tried to fix this problem to create a internal and external relay domain with the appropriate send connector but
    this didn’t help.
    When we remove the proxyaddress attribute in the local active directory we are able to send email from the on premise exchange server to Office365. Removing the proxyaddresses is not a solution because these settings will be synced to
    Office 365 and users can’t receive email anymore in there cloud mailbox.
    It looks like the SMTP Categorizer first looks in active directory if the target email addresses is available. If so it will send the email to this users (but doesn’t have a mailbox server and mailbox database).
    Can we configure a working mailflow for email from on premise to Office 365 for @companyname.com addresses?

    Hi,
    Please try to set the target Address from the on premise AD account in ADSIedit to match the Cloud mailbox address, and then check the result.
    In addition, I recommend you post this thread on office 365 forum:
    http://community.office365.com/en-us/forums/default.aspx
    Hope this helps!
    Thanks.
    Niko Cheng
    TechNet Community Support

  • Could not send notification 65569 (status 'FAILED')

    Customize Workflow runs with 2006 error - only happen in the morning
    We have created a customize workflow which works a bit funny here:
    When we first run the workflow in the morning, it ends up with this error:
    Activity Buyer Notifications
    Result Mail
    Error Name WFMLRSND_FAILED
    Error Message 2006: Could not send notification 65569 (status 'FAILED') to 'CONTRACT SERVICES'.
    Error Stack WF_MAIL.GetDocContent(PO_DETAILS_BUYER)
    Then, thinking of some problem might happend to the workflow mailer, we run the standard workflow, e.g. PO Approval. It runs successfully and send out the notification email. So, we then run the customise workflow again, and this time it works, no error has been generated as above.
    The funny thing is, this had happened more than a week, where every morning I have to somehow run a standard workflow (normally I just create a new PO and send for approval), and got my customize workflow run successfully.
    Can someone highlight what's going wrong here?
    Is that some setup or soemthing that contribute to this problem?
    Thanks,
    Patricia

    The notifications are defined in the workflow but they do use a document type attribute (we send a table of data "Job", "Job Name", "Amounts").
    We have changed the database packages a lot and that created many problems afterwards so we minimized when we make those changes and we restart everything (database, IAS Server) afterwards.
    Here is the email to SYSADMIN:
    =========================================================
    Subject: Error in Workflow DUNAPIN2/20060323123955x30741282 2006: Could not send notification 41119 (status 'ERROR') to 'KKEMPER'.
    From
    To SYSADMIN
    Sent 03-APR-06
    Due
    Notification ID 41121
    An Error occurred in the following Workflow.
    Item Type = DUNAPIN2
    Item Key = 20060323123955x30741282
    User Key =20060323123955x30741282
    Error Name = WFMLRSND_FAILED
    Error Message = 2006: Could not send notification 41119 (status 'ERROR') to 'KKEMPER'.
    Error Stack = &ERROR_STACK
    Activity Id = 52557
    Activity Label = GET_GENERAL_LEDGER_APPROVAL:NTF_V2_AR_DEPT_OFF_MGR
    Result Code = #MAIL
    Notification Id = 41119
    Assigned User = KKEMPER
    Workflow monitor
    Please click on one of the following choices to automatically generate an E-mail response. Before sending the E-mail response to close this notification, ensure all response prompts include a desired response value within quotes.
    How do you want to Continue?
    How do you want to continue?: Abort Resolved Retry Request information
    =========================================================
    Any help would be greatly appreciated.
    Jim

  • Setting maximum packet size in JDBC driver to send data to database

    Could someone tell me how I can set the JDBC connection property of maximum packet size to send data to database?
    Regards
    Rashed

    Hi thanks....I'm having this strange SQLException while trying to insert BLOB image data to Oracle database. I'm saying this strange because for the same image that has been inserted before it's throwing the exception. My program is run from Oracle form and then some image data are inserted into database through a loop. I can't realize what's the problem inside my code that's causing this problem. In fact, when I run my program independently not from Oracle Form, it runs fine, every image data get inserted into database. Given below is my code snippet:
    public void insertAccDocs(String[] accessions) throws SQLException
        for(int q=0; q<accessions.length; q++)
        final String  docName = accessions[q];
        dbThread = new Thread(new Runnable(){
        public void run()
          try{
          System.out.println("insertDB before connection");
                   getConnected();
                   System.out.println("insertDB after connection");
                   st=con.createStatement();
             //String docName = acc; commented
         // String docName = singleAccession;
                   String text = formatFree;
                   String qry = "INSERT INTO DOCUMENT VALUES
    ('"+docName+"','"+text+"','"+formatted+"','"+uiid+"')";
                   System.out.println("parentqry"+qry);
                   int ok=0;
                   ok=st.executeUpdate(qry);
                   if(ok==1)
                System.out.println("INSERTION SUCCESS= "+ok);
                        System.out.println("Image List Size"+ imgList.size());
                // inserting into child
                        for(int i=0;i<imgList.size(); i++)
                      String imgPath = ""+imgList.get(i);
                                  System.out.println("db"+imgPath);
                                  FileInputStream fin = new FileInputStream(imgPath);
                                  BufferedInputStream bufStr = new BufferedInputStream(fin);
                                  byte[] imgByte = new byte[bufStr.available()];
                                  String img = "" + imgNameList.get(i);
                                  System.out.println("imgid="+i);
                callable = con.prepareCall("{call prc_insert_docimage(?,?,?)}");
                callable.setString(1,docName);
                            callable.setString(2,img);
                callable.setBinaryStream(3, bufStr , (int)imgByte.length);
                callable.execute();
            callable.close();
                     con.commit();
            con.close();
                   else
                        System.out.println("INSERTION NOT SUCCESS");
       //   } //else end of severalAcc
                   }catch(Exception err){ //try
                        System.out.println(err.toString());
        } //run
      }); //runnable
      dbThread.start();     
    }And the exception thrown is :
    java.sql.SQLException: Data size bigger than max size for this type: #####
    Please let me know if possible how I can get around this.
    Regards
    Rashed

  • AP 1252 in autonomous mode not sending framed-ip-address

    I was attempting to use the Websense RADIUS Agent to transparently map wireless users in it's database. This is done by passing the RADIUS accounting packets through the websense server where Websense can read them and map the username and password. This works for our Cisco VPN clients and Anyconnect clients. The problem I have is that the 1252 AP does not send the framed-ip-address in the RADIUS accounting packet. The AP should know the client IP since it can be seen with "show dot11 association".
    For whatever reason, the AP doesn't know the IP address. This is verified by enabling aaa acounting delay-start which delays the sending accounting packets until the peer IP is known. With this command in, no accounting packets are ever sent from the AP.
    Does anyone know why the AP doesn't include the framed-ip-address in the accounting packets? Or, why the AP is not able to learn the peer IP address from the client association information?
    Thanks,
    Mark

    For a session to be disconnected, the values in one or more of the key fields in the POD request must match the values for a session on one of the network access server ports. Which values must match depends on the auth-type attribute defined in the command. If noauth-type is specified, all four values must match. If no match is found, all connections remain intact and an error response is returned. The key fields are as follows:
    User-Name
    Framed-IP-Address
    Session-Id
    Server-Key

  • Server not found in Kerberos database (7)

    Hi!
    Running the examples from
    http://java.sun.com/javase/6/docs/technotes/guides/security/jgss/lab
    works fine for me as long as I use the Kerberos test realm I have set up on a unix machine. But when I run the same classes against our Active Directory, the client spills a stacktrace, indicating that AD can not find the server in its database. But it actually is in that database, as the sample server can perfectly authenticate as exactly that principal!
    Enabling all security related debug info i could find, this is the client dump:
    $ java -Djava.security.auth.login.config=jaas-krb5.conf
         -Djava.security.krb5.kdc=##KDC##
         -Djava.security.krb5.realm=##REALM##
         -Dsun.security.jgss.debug=true
         -Dsun.security.krb5.debug=true
         -Djava.security.debug="logincontext,policy,scl,gssloginconfig"
         GssClient host ##SERVER##
    scl:  getPermissions ProtectionDomain  (file:/xxxxx/ <no signer certificates>)
    sun.misc.Launcher$AppClassLoader@11b86e7
    <no principals>
    java.security.Permissions@1a46e30 (
    (java.io.FilePermission \xxxxx\- read)
    (java.lang.RuntimePermission exitVM)
    scl:
    Debug is  true storeKey false useTicketCache true useKeyTab true doNotPrompt false ticketCache is nu
    ll isInitiator true KeyTab is null refreshKrb5Config is false principal is xxxxx tryFirstPass is tru
    e useFirstPass is false storePass is false clearPass is false
    Acquire TGT from Cache
    KinitOptions cache name is C:\xxxxxAcquire default native Credentials
    Obtained TGT from LSA: Credentials:
    client=##USER##@##REALM##
    server=krbtgt/##REALM##@##REALM##
    authTime=20070705103930Z
    startTime=20070705103930Z
    endTime=20070705203930Z
    renewTill=20070712103930Z
    flags: FORWARDABLE;RENEWABLE;INITIAL;PRE-AUTHENT
    EType (int): 23
    Principal is ##USER##@##REALM##
                    [Krb5LoginModule] authentication succeeded
            [LoginContext]: login success
    Commit Succeeded
            [LoginContext]: commit success
    Authenticated principal: [##USER##@##REALM##]
    Connected to address ##SERVER##/xxxxx
    xxxxx
    create server name with host@##SERVER##
    Search Subject for Kerberos V5 INIT cred (<<DEF>>, sun.security.jgss.krb5.Krb5InitCredential)
    Found ticket for ##USER##@##REALM## to go to krbtgt/##REALM##@##REALM## expiring on Thu Jul
    05 20:39:30 GMT 2007
    Entered Krb5Context.initSecContext with state=STATE_NEW
    Found ticket for ##USER##@##REALM## to go to krbtgt/##REALM##@##REALM## expiring on Thu Jul
    05 20:39:30 GMT 2007
    Service ticket not found in the subject
    Credentials acquireServiceCreds: same realmUsing builtin default etypes for default_tgs_enctypes
    default etypes for default_tgs_enctypes: 3 1 23 16 17.
    CksumType: sun.security.krb5.internal.crypto.RsaMd5CksumType
    EType: sun.security.krb5.internal.crypto.ArcFourHmacEType
    KrbKdcReq send: kdc=##KDC## UDP:88, timeout=30000, number of retries =3, #bytes=1328
    KDCCommunication: kdc=##KDC## UDP:88, timeout=30000,Attempt =1, #bytes=1328
    KrbKdcReq send: #bytes read=101
    KrbKdcReq send: #bytes read=101
    KDCRep: init() encoding tag is 126 req type is 13
    KRBError:         sTime is Thu Jul 05 14:43:05 GMT 2007 1183646585000
             suSec is 487997
             error code is 7
             error Message is Server not found in Kerberos database
             realm is ##REALM##
             sname is host/##SERVER##
             msgType is 30
    KrbException: Server not found in Kerberos database (7)
            at sun.security.krb5.KrbTgsRep.<init>(Unknown Source)
            at sun.security.krb5.KrbTgsReq.getReply(Unknown Source)
            at sun.security.krb5.internal.CredentialsUtil.serviceCreds(Unknown Source)
            at sun.security.krb5.internal.CredentialsUtil.acquireServiceCreds(Unknown Source)
            at sun.security.krb5.Credentials.acquireServiceCreds(Unknown Source)
            at sun.security.jgss.krb5.Krb5Context.initSecContext(Unknown Source)
            at sun.security.jgss.GSSContextImpl.initSecContext(Unknown Source)
            at sun.security.jgss.GSSContextImpl.initSecContext(Unknown Source)
            at GssClient$GssClientAction.run(GssClient.java:171)
            at java.security.AccessController.doPrivileged(Native Method)
            at javax.security.auth.Subject.doAs(Unknown Source)
            at Jaas.loginAndAction(Jaas.java:94)
            at GssClient.main(GssClient.java:97)
    Caused by: KrbException: Identifier doesn't match expected value (906)
            at sun.security.krb5.internal.KDCRep.init(Unknown Source)
            at sun.security.krb5.internal.TGSRep.init(Unknown Source)
            at sun.security.krb5.internal.TGSRep.<init>(Unknown Source)
            ... 13 more
    Exception in thread "main" java.security.PrivilegedActionException: GSSException: No valid credentia
    ls provided (Mechanism level: Server not found in Kerberos database (7))
            at java.security.AccessController.doPrivileged(Native Method)
            at javax.security.auth.Subject.doAs(Unknown Source)
            at Jaas.loginAndAction(Jaas.java:94)
            at GssClient.main(GssClient.java:97)
    Caused by: GSSException: No valid credentials provided (Mechanism level: Server not found in Kerbero
    s database (7))
            at sun.security.jgss.krb5.Krb5Context.initSecContext(Unknown Source)
            at sun.security.jgss.GSSContextImpl.initSecContext(Unknown Source)
            at sun.security.jgss.GSSContextImpl.initSecContext(Unknown Source)
            at GssClient$GssClientAction.run(GssClient.java:171)
            ... 4 more
    Caused by: KrbException: Server not found in Kerberos database (7)
            at sun.security.krb5.KrbTgsRep.<init>(Unknown Source)
            at sun.security.krb5.KrbTgsReq.getReply(Unknown Source)
            at sun.security.krb5.internal.CredentialsUtil.serviceCreds(Unknown Source)
            at sun.security.krb5.internal.CredentialsUtil.acquireServiceCreds(Unknown Source)
            at sun.security.krb5.Credentials.acquireServiceCreds(Unknown Source)
            ... 8 more
    Caused by: KrbException: Identifier doesn't match expected value (906)
            at sun.security.krb5.internal.KDCRep.init(Unknown Source)
            at sun.security.krb5.internal.TGSRep.init(Unknown Source)
            at sun.security.krb5.internal.TGSRep.<init>(Unknown Source)
            ... 13 moreWhy's AD claiming in the KRBError that it can't find a sname/realm which exactly matches the principal it accepted for the server? This totally confuses me! Can please anyone bring some light?
    Regards

    It works now!!!
    The exact procedure is:
    - Create a new user in AD with an arbitrary name <username>. Use the same name in "User Logon Name", "User Logon Name (pre Win2K)" and "First Name" (odd, isn't it).
    - Set the password, deactivate "User has to change the password at first logon", and activate "Password never expires"
    - Create a mapping for the service name by entering into the command line: ktpass -princ "<protocol>/<fqdn>@<realm>" -mapuser "<username>@<realm>" -pass "*" -out dummy.keytab
    - Check that the mapping is set and unique; use adsiedit.msc (Windows Support Tools).
    - Now you can use the Java tool ktab to create your own keytab as usual and go.
    But it is a science in its own right to correctly configure an Active Directory , especially for use with Kerberos. In particular error messages are hardly useful (as it is generally the case in the Kerberos world). It may help to read:
    http://www.microsoft.com/downloads/details.aspx?FamilyID=99b0f94f-e28a-4726-bffe-2f64ae2f59a2&DisplayLang=en
    and
    http://www.microsoft.com/downloads/details.aspx?FamilyID=7dfeb015-6043-47db-8238-dc7af89c93f1&displaylang=en
    Have fun!

Maybe you are looking for