How to store an image into MySQL db using BlazeDS and Hibernate?

Hi!
I am using Flash Builder 4.6, BlazeDS, and Hibernate. How to store a webcam snapshot into the MySql Database. I stored Form Items by using RemoteObject into the database. But I failed to store webcam snapshot. I captured that image on Panel component.I converted that image to ByteArray. Now I want to save that image into the database. Please help me in this regard.
thanks in advance.
Here the Code:
VisitorEntryForm.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow
          xmlns:mx="http://www.adobe.com/2006/mxml"
          xmlns:vo="com.visitor.vo.*"
          width="600"
          height="300"
          defaultButton="{submitButton}"
          showCloseButton="true"
          creationComplete="creationCompleteHandler();"
          close="PopUpManager.removePopUp(this);"
          title="Visitor Entry Form" xmlns:text="flash.text.*">
          <mx:RemoteObject id="saveService" destination="visitorService" result="handleSaveResult(event)" fault="handleFault(event)" showBusyCursor="true" />
          <vo:Visitor id="visitor"
                                           vType="{vTypeField.text}"
                                           vPurpose="{vPurposeField.text}"
                                           vName="{vNameField.text}"
                                           vAddress="{vAddressField.text}"
                                           cPerson="{cPersonField.text}"
                                           cAddress="{cAddressField.text}"
                                 />
                    <mx:Script>
                    <![CDATA[
                    import mx.managers.PopUpManager;
                    import flash.media.Camera;
                    import com.visitor.vo.WebCam;
                    import com.visitor.vo.Base64;
                    import mx.core.UIComponent;
                    import mx.graphics.codec.JPEGEncoder;
                    import mx.controls.Alert;
                    import mx.containers.Canvas;
                    import mx.rpc.events.ResultEvent;
                    import mx.rpc.events.FaultEvent;
                    import mx.events.ValidationResultEvent;
                    import mx.validators.Validator;
                              [Bindable]
                              private var webCam: com.visitor.vo.WebCam;
                              [Bindable]
                              private var message:String;
                              [Bindable]
                              private var formIsValid:Boolean = false;
                              [Bindable]
                              public var formIsEmpty:Boolean;
                              private var focussedFormControl:DisplayObject;
                              private function handleSaveResult(ev:ResultEvent):void {
                                        clearFormHandler();
                                        validateForm(ev);
                                        Alert.show("Visitor successfully created/updated.", "Information", Alert.OK, null, null, null, Alert.OK);
                                        // Reload the list.
                                        parentApplication.listConsultants.loaderService.getConsultants();
                                        PopUpManager.removePopUp(this);
                              private function handleFault(ev:FaultEvent):void {
                                        message = "Error: " + ev.fault.faultCode + " \n "
                                                  + "Detail: " + ev.fault.faultDetail + " \n "
                                                  + "Message: " + ev.fault.faultString;
                              public function saveVisitor():void {
                                        saveService.addUpdateVisitor(visitor);
                              private function creationCompleteHandler():void {
                                        init();
                                        PopUpManager.centerPopUp(this);
                                        resetFocus();
                              private function resetFocus():void {
                                        focusManager.setFocus(vTypeField);
                              public function validateForm(event:Event):void  {
                                        focussedFormControl = event.target as DisplayObject;   
                                        formIsValid = true;
                                        // Check if form is empty
                                        formIsEmpty = (vTypeField.text == "" && vPurposeField.text == "" && vNameField.text == "" && vAddressField.text == "" && cPersonField.text == "" && cAddressField.text == "");
                                        validate(vTypeValidator);               
                                        validate(vPurposeValidator);
                                        validate(vNameValidator);
                                        validate(vAddressValidator);
                                        validate(cPersonValidator);
                                        validate(cAddressValidator);
                              private function validate(validator:Validator):Boolean {
                                        var validatorSource:DisplayObject = validator.source as DisplayObject;
                                        var suppressEvents:Boolean = (validatorSource != focussedFormControl);
                                        var event:ValidationResultEvent = validator.validate(null, suppressEvents);
                                        var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID);
                                        formIsValid = formIsValid && currentControlIsValid;
                                        return currentControlIsValid;
                              private function clearFormHandler():void {
                                        // Clear all input fields.
                                        vTypeField.text = "";
                                        vPurposeField.text = "";
                                        vNameField.text = "";
                                        vAddressField.text = "";
                                        cPersonField.text = "";
                                        cAddressField.text = "";
                                        message = "";
                                        // Clear validation error messages.
                                        vTypeField.errorString = "";
                                        vPurposeField.errorString = "";
                                        vNameField.errorString = "";
                                        vAddressField.errorString = "";
                                        cPersonField.errorString = "";
                                        cAddressField.errorString = "";
                                        formIsEmpty = true;
                                        formIsValid = false;
                                        resetFocus();
                              private function init():void {
                              webCam = new WebCam(97,97);
                              var ref:UIComponent = new UIComponent();
                              preview.removeAllChildren();
                              preview.addChild(ref);
                              ref.addChild(webCam);
                              private function takeSnapshot():void {
                              imageViewer.visible = true;
                              imageViewer.width = preview.width;
                              imageViewer.height = preview.height;
                              var uiComponent : UIComponent = new UIComponent();
                              uiComponent.width = webCam.width;
                              uiComponent.height = webCam.height;
                              var photoData:Bitmap = webCam.getSnapshot();
                              var photoBitmap:BitmapData = photoData.bitmapData;
                              uiComponent.addChild(photoData);
                              imageViewer.removeAllChildren();
                              imageViewer.addChild(uiComponent);
                              private function uploadSnapshot():void
                                        if (imageViewer.getChildren().length > 0)
                                                  var uic:UIComponent = imageViewer.getChildAt(0) as UIComponent;
                                                  var bitmap:Bitmap = uic.getChildAt(0) as Bitmap;
                                                  var jpgEncoder:JPEGEncoder = new JPEGEncoder(75);
                                                  var jpgBytes:ByteArray = jpgEncoder.encode(bitmap.bitmapData);
                              private function deleteSnapshot():void
                                        imageViewer.removeAllChildren();
                    ]]>
                    </mx:Script>
          <mx:StringValidator id="vTypeValidator"          source="{vTypeField}"          property="text" minLength="2" required="true" />
          <mx:StringValidator id="vPurposeValidator" source="{vPurposeField}"          property="text" minLength="2" required="true" />
          <mx:StringValidator id="vNameValidator"          source="{vNameField}"          property="text" minLength="2" required="true" />
          <mx:StringValidator id="vAddressValidator"          source="{vAddressField}"          property="text" minLength="5" required="true" />
          <mx:StringValidator id="cPersonValidator" source="{cPersonField}"          property="text" minLength="2" required="true" />
          <mx:StringValidator id="cAddressValidator"          source="{cAddressField}"          property="text" minLength="5" required="true" />
          <mx:Grid width="575" height="211">
                    <mx:GridRow width="575" height="211">
                              <mx:GridItem width="301" height="235">
                                        <mx:Form width="301" height="208">
                                                  <mx:FormItem label="Visitor's Type">
                                                            <mx:ComboBox id="vTypeField" text="{visitor.vType}" change="validateForm(event);" editable="true">
                                                                      <mx:Array>
                                                                                <mx:String></mx:String>
                                                                                <mx:String>Contractor</mx:String>
                                                                                <mx:String>Supplier</mx:String>
                                                                                <mx:String>Transporter</mx:String>
                                                                                <mx:String>Plant</mx:String>
                                                                                <mx:String>Non-Plant</mx:String>
                                                                      </mx:Array>
                                                            </mx:ComboBox>
                                                  </mx:FormItem>
                                                  <mx:FormItem label="Visit Purpose">
                                                            <mx:ComboBox id="vPurposeField" text="{visitor.vPurpose}" change="validateForm(event);" editable="true">
                                                                      <mx:Array>
                                                                                <mx:String></mx:String>
                                                                                <mx:String>Official</mx:String>
                                                                                <mx:String>Personal</mx:String>
                                                                      </mx:Array>
                                                            </mx:ComboBox>
                                                  </mx:FormItem>
                                                  <mx:FormItem label="Visitor's Name">
                                                            <mx:TextInput id="vNameField"  text="{visitor.vName}" change="validateForm(event);"/>
                                                  </mx:FormItem>
                                                  <mx:FormItem label="Address">
                                                            <mx:TextInput id="vAddressField"   text="{visitor.vAddress}" change="validateForm(event);"/>
                                                  </mx:FormItem>
                                                  <mx:FormItem label="Contact Person">
                                                            <mx:TextInput id="cPersonField"  text="{visitor.cPerson}" change="validateForm(event);"/>
                                                  </mx:FormItem>
                                                  <mx:FormItem label="Address">
                                                            <mx:TextInput id="cAddressField"  text="{visitor.cAddress}" change="validateForm(event);"/>
                                                  </mx:FormItem>
                                                  </mx:Form>
                              </mx:GridItem>
                              <mx:GridItem width="264" height="193">
                                        <mx:Grid width="241" height="206">
                                                  <mx:GridRow width="100%" height="100%">
                                                            <mx:GridItem width="100%" height="100%" horizontalAlign="center" verticalAlign="middle">
                                                                      <mx:Panel width="100" height="132" title="Snap" id="preview" layout="absolute"/>
                                                            </mx:GridItem>
                                                            <mx:GridItem width="100%" height="100%" horizontalAlign="center" verticalAlign="middle">
                                                                      <mx:Panel width="100" height="132" title="Preview" id="imageViewer"  layout="absolute"/>
                                                            </mx:GridItem>
                                                  </mx:GridRow>
                                                  <mx:GridRow width="100%" height="27" >
                                                            <mx:GridItem width="100%" height="100%" horizontalAlign="center">
                                                                      <mx:Button id="snapshot" x="2" width="106" height="27" label="Snap"
                                                                                              click="takeSnapshot();"/>
                                                            </mx:GridItem>
                                                            <mx:GridItem width="100%" height="100%" horizontalAlign="center">
                                                                      <mx:Button id="deleteButton" x="1" width="106" height="27" label="Delete"
                                                                                              click="deleteSnapshot();"/>
                                                            </mx:GridItem>
                                                  </mx:GridRow>
                                        </mx:Grid>
                              </mx:GridItem>
                    </mx:GridRow>
          </mx:Grid>
          <mx:ControlBar height="40" horizontalAlign="center">
                    <mx:Button label="Save Visitor"          id="submitButton" enabled="{formIsValid}" click="saveVisitor();" />
                    <mx:Button label="Clear form" enabled="{!formIsEmpty}"          click="clearFormHandler();" />
                    <mx:Button label="Cancel" click="PopUpManager.removePopUp(this);"/>
                    <mx:Label width="211" id="state"/>
          </mx:ControlBar>
          <mx:Text text="{message}" fontWeight="bold" width="300"/>
</mx:TitleWindow>
ListVisitors.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel
          xmlns:mx="http://www.adobe.com/2006/mxml"
          xmlns:view="com.visitor.view.*"
          width="100%"
          height="100%"
          title="Visitor Management System - Found {visitorRecords} visitors."
          creationComplete="loadVisitors();">
          <mx:RemoteObject id="loaderService" destination="visitorService" result="handleLoadResult(event)"          fault="handleFault(event)" showBusyCursor="true" />
          <mx:RemoteObject id="deleteService" destination="visitorService" result="handleDeleteResult(event)"          fault="handleFault(event)" showBusyCursor="true" />
          <mx:Script>
                    <![CDATA[
                              import com.visitor.vo.Visitor;
                              import mx.controls.Alert;
                              import mx.managers.PopUpManager;
                              import mx.containers.TitleWindow;
                              import mx.collections.ArrayCollection;
                              import mx.rpc.events.ResultEvent;
                              import mx.rpc.events.FaultEvent;
                              [Bindable]
                              private var message:String;
                              [Bindable]
                              private var visitors:ArrayCollection = new ArrayCollection();
                              [Bindable]
                              private var visitorRecords:int = 0;
                              public function loadVisitors():void {
                                        loaderService.getVisitors();
                              private function deleteVisitor():void {
                                        if(dataGrid.selectedItem != null) {
                                                  var selectedItem:Visitor = dataGrid.selectedItem as Visitor;
                                                  deleteService.deleteVisitor(selectedItem.visitorId);
                              private function createVisitor():void {
                                        var titleWindow:VisitorEntryForm = VisitorEntryForm(PopUpManager.createPopUp(this, VisitorEntryForm, true));
                                        titleWindow.setStyle("borderAlpha", 0.9);
                                        titleWindow.formIsEmpty = true;
                              private function updateVisitor():void {
                                        var titleWindow:VisitorEntryForm = VisitorEntryForm(PopUpManager.createPopUp(this, VisitorEntryForm, true));
                                        titleWindow.setStyle("borderAlpha", 0.9);
                                        titleWindow.visitor = dataGrid.selectedItem as Visitor;
                                        titleWindow.formIsEmpty = false;
                              private function handleLoadResult(ev:ResultEvent):void {
                                        visitors = ev.result as ArrayCollection;
                                        visitorRecords = visitors.length;
                              private function handleDeleteResult(ev:ResultEvent):void {
                                        Alert.show("The visitor has been deleted.", "Information", Alert.OK, null, null, null, Alert.OK);
                                        loadVisitors();
                              private function handleFault(ev:FaultEvent):void {
                                        message = "Error: "
                                                  + ev.fault.faultCode + " - "
                                                  + ev.fault.faultDetail + " - "
                                                  + ev.fault.faultString;
                    ]]>
          </mx:Script>
          <mx:VBox width="100%" height="100%">
                    <mx:Label text="{message}" fontWeight="bold" includeInLayout="false" />
                    <mx:DataGrid
                              id="dataGrid"
                              width="100%"
                              height="100%"
                              dataProvider="{visitors}"
                              doubleClickEnabled="true"
                              doubleClick="updateVisitor()" >
                              <mx:columns>
                                        <mx:DataGridColumn dataField="visitorId"          headerText="Visitor ID" width="100"/>
                                        <mx:DataGridColumn dataField="vType"                    headerText="Visitor's Type" />
                                        <mx:DataGridColumn dataField="vPurpose"           headerText="Visit Purpose" />
                                        <mx:DataGridColumn dataField="vName"                     headerText="Visitor's Name" />
                                        <mx:DataGridColumn dataField="vAddress"                    headerText="Visitor's Address" />
                                        <mx:DataGridColumn dataField="cPerson"                     headerText="Contact Person" />
                                        <mx:DataGridColumn dataField="cAddress"                    headerText="Contact Address" />
                                        <mx:DataGridColumn dataField="timeIn"                     headerText="Time-In" />
                                        <mx:DataGridColumn dataField="timeOut"                     headerText="Time-Out" />
                                        <mx:DataGridColumn dataField="vPhoto"                     headerText="Visitor's Photo" />
                              </mx:columns>
                    </mx:DataGrid>
                    <mx:ControlBar horizontalAlign="center">
                              <mx:Button label="Create Visitor"          click="createVisitor()"          toolTip="Create a new visitor and store it in the database." />
                              <mx:Button label="Update Visitor"          click="updateVisitor()"           enabled="{dataGrid.selectedItem}" toolTip="Update an existing database visitor." />
                              <mx:Button label="Delete Visitor"          click="deleteVisitor()"          enabled="{dataGrid.selectedItem}" toolTip="Delete the visitor from the database." />
                              <mx:Button label="Reload Data"                    click="loadVisitors()"           toolTip="Reload the visitor list from the database." />
                    </mx:ControlBar>
          </mx:VBox>
</mx:Panel>
Visitor.as
package com.visitor.vo
          import mx.controls.Image;
          import spark.primitives.BitmapImage;
          [Bindable]
          [RemoteClass(alias="com.visitor.Visitor")]
          public class Visitor
                    public function Visitor()
                    public var visitorId:Number;
                    public var vType:String;
                    public var vPurpose:String;
                    public var vName:String;
                    public var vAddress:String;
                    public var cPerson:String;
                    public var cAddress:String;
                    public var timeIn:Date;
                    public var timeOut:Date;
                   public var vPhoto: Image;
Visitor.java
package com.visitor;
import java.sql.Blob;
import java.sql.Timestamp;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import org.hibernate.annotations.Index;
@Entity
@Table(name = "visitors")
@NamedQueries( {
                    @NamedQuery(name = "visitors.findAll", query = "from Visitor"),
                    @NamedQuery(name = "visitors.byId", query = "select v from Visitor v where v.visitorId= :visitorId") })
public class Visitor {
          @Id
          @GeneratedValue(strategy = GenerationType.AUTO)
          @Column(name = "visitorId", nullable = false)
          private Long visitorId;
          @Basic
          @Index(name = "vType_idx_1")
          @Column(name = "vType", nullable = true, unique = false)
          private String vType;
          @Basic
          @Column(name = "vPurpose", nullable = true, unique = false)
          private String vPurpose;
          @Basic
          @Column(name = "vName", nullable = true, unique = false)
          private String vName;
          @Basic
          @Column(name = "vAddress", nullable = true, unique = false)
          private String vAddress;
          @Basic
          @Column(name = "cPerson", nullable = true, unique = false)
          private String cPerson;
          @Basic
          @Column(name = "cAddress", nullable = true, unique = false)
          private String cAddress;
          @Basic
          @Column(name = "timeIn", nullable = false, unique = false)
          private Timestamp timeIn;
          @Basic
          @Column(name = "timeOut", nullable = true, unique = false)
          private Timestamp timeOut;
          @Basic
          @Column(name = "vPhoto", nullable = true, unique = false)
          private Blob vPhoto;
          public Visitor() {
                    super();
          public Long getVisitorId() {
                    return visitorId;
          public void setVisitorId(Long visitorId) {
                    this.visitorId = visitorId;
          public String getvType() {
                    return vType;
          public void setvType(String vType) {
                    this.vType = vType;
          public String getvPurpose() {
                    return vPurpose;
          public void setvPurpose(String vPurpose) {
                    this.vPurpose = vPurpose;
          public String getvName() {
                    return vName;
          public void setvName(String vName) {
                    this.vName = vName;
          public String getvAddress() {
                    return vAddress;
          public void setvAddress(String vAddress) {
                    this.vAddress = vAddress;
          public String getcPerson() {
                    return cPerson;
          public void setcPerson(String cPerson) {
                    this.cPerson = cPerson;
          public String getcAddress() {
                    return cAddress;
          public void setcAddress(String cAddress) {
                    this.cAddress = cAddress;
          public Timestamp getTimeIn() {
                    return timeIn;
          public void setTimeIn(Timestamp timeIn) {
                    this.timeIn = timeIn;
          public Timestamp getTimeOut() {
                    return timeOut;
          public void setTimeOut(Timestamp timeOut) {
                    this.timeOut = timeOut;
          public Blob getvPhoto() {
                    return vPhoto;
          public void setvPhoto(Blob vPhoto) {
                    this.vPhoto = vPhoto;
VisitorService.java
package com.visitor;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import javax.persistence.Query;
import org.apache.log4j.Logger;
public class VisitorService {
          private static final String PERSISTENCE_UNIT = "visitor_db";
          private static Logger logger = Logger.getLogger(VisitorService.class);
          public VisitorService() {
                    super();
          public List<Visitor> getvisitors() {
                    logger.debug("** getVisitors called...");
                    EntityManagerFactory entityManagerFactory = Persistence
                                        .createEntityManagerFactory(PERSISTENCE_UNIT);
                    EntityManager em = entityManagerFactory.createEntityManager();
                    Query findAllQuery = em.createNamedQuery("visitors.findAll");
                    List<Visitor> visitors = findAllQuery.getResultList();
                    if (visitors != null)
                              logger.debug("** Found " + visitors.size() + " records:");
                    return visitors;
          public void addUpdateVisitor(Visitor visitor) throws Exception {
                    logger.debug("** addUpdateVisitor called...");
                    EntityManagerFactory emf = Persistence
                                        .createEntityManagerFactory(PERSISTENCE_UNIT);
                    EntityManager em = emf.createEntityManager();
                    // When passing Boolean and Number values from the Flash client to a
                    // Java object, Java interprets null values as the default values for
                    // primitive types; for example, 0 for double, float, long, int, short,
                    // byte.
                    if (visitor.getVisitorId() == null          || visitor.getVisitorId() == 0) {
                              // New consultant is created
                              visitor.setVisitorId(null);
                              visitor.setTimeIn(new Timestamp(new Date().getTime()));
                    } else {
                              visitor.setTimeOut(new Timestamp(new Date().getTime()));
                              // Existing consultant is updated - do nothing.
                    EntityTransaction tx = em.getTransaction();
                    tx.begin();
                    try {
                              em.merge(visitor);
                              tx.commit();
                    } catch (Exception e) {
                              logger.error("** Error: " + e.getMessage());
                              tx.rollback();
                              throw new Exception(e.getMessage());
                    } finally {
                              logger.info("** Closing Entity Manager.");
                              em.close();
          public void deleteVisitor(Long visitorId) {
                    logger.debug("** deleteVisitor called...");
                    EntityManagerFactory emf = Persistence
                                        .createEntityManagerFactory(PERSISTENCE_UNIT);
                    EntityManager em = emf.createEntityManager();
                    Query q = em.createNamedQuery("visitors.byId");
                    q.setParameter("visitorId", visitorId);
                    Visitor visitor = (Visitor) q.getSingleResult();
                    if (visitor != null) {
                              EntityTransaction tx = em.getTransaction();
                              tx.begin();
                              try {
                                        em.remove(visitor);
                                        tx.commit();
                              } catch (Exception e) {
                                        logger.error("** Error: " + e.getMessage());
                                        tx.rollback();
                              } finally {
                                        logger.info("** Closing Entity Manager.");
                                        em.close();
remoting-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<service id="remoting-service" class="flex.messaging.services.RemotingService">
          <adapters>
                    <adapter-definition id="java-object"
                              class="flex.messaging.services.remoting.adapters.JavaAdapter"
                              default="true" />
          </adapters>
          <default-channels>
                    <channel ref="my-amf" />
          </default-channels>
          <!-- ADC Demo application -->
          <destination id="visitorService">
                    <properties>
                              <source>com.visitor.VisitorService</source>
                    </properties>
          </destination>
</service>

Hi!
I am using Flash Builder 4.6, BlazeDS, and Hibernate. How to store a webcam snapshot into the MySql Database. I stored Form Items by using RemoteObject into the database. But I failed to store webcam snapshot. I captured that image on Panel component.I converted that image to ByteArray. Now I want to save that image into the database. Please help me in this regard.
thanks in advance.
Here the Code:
VisitorEntryForm.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow
          xmlns:mx="http://www.adobe.com/2006/mxml"
          xmlns:vo="com.visitor.vo.*"
          width="600"
          height="300"
          defaultButton="{submitButton}"
          showCloseButton="true"
          creationComplete="creationCompleteHandler();"
          close="PopUpManager.removePopUp(this);"
          title="Visitor Entry Form" xmlns:text="flash.text.*">
          <mx:RemoteObject id="saveService" destination="visitorService" result="handleSaveResult(event)" fault="handleFault(event)" showBusyCursor="true" />
          <vo:Visitor id="visitor"
                                           vType="{vTypeField.text}"
                                           vPurpose="{vPurposeField.text}"
                                           vName="{vNameField.text}"
                                           vAddress="{vAddressField.text}"
                                           cPerson="{cPersonField.text}"
                                           cAddress="{cAddressField.text}"
                                 />
                    <mx:Script>
                    <![CDATA[
                    import mx.managers.PopUpManager;
                    import flash.media.Camera;
                    import com.visitor.vo.WebCam;
                    import com.visitor.vo.Base64;
                    import mx.core.UIComponent;
                    import mx.graphics.codec.JPEGEncoder;
                    import mx.controls.Alert;
                    import mx.containers.Canvas;
                    import mx.rpc.events.ResultEvent;
                    import mx.rpc.events.FaultEvent;
                    import mx.events.ValidationResultEvent;
                    import mx.validators.Validator;
                              [Bindable]
                              private var webCam: com.visitor.vo.WebCam;
                              [Bindable]
                              private var message:String;
                              [Bindable]
                              private var formIsValid:Boolean = false;
                              [Bindable]
                              public var formIsEmpty:Boolean;
                              private var focussedFormControl:DisplayObject;
                              private function handleSaveResult(ev:ResultEvent):void {
                                        clearFormHandler();
                                        validateForm(ev);
                                        Alert.show("Visitor successfully created/updated.", "Information", Alert.OK, null, null, null, Alert.OK);
                                        // Reload the list.
                                        parentApplication.listConsultants.loaderService.getConsultants();
                                        PopUpManager.removePopUp(this);
                              private function handleFault(ev:FaultEvent):void {
                                        message = "Error: " + ev.fault.faultCode + " \n "
                                                  + "Detail: " + ev.fault.faultDetail + " \n "
                                                  + "Message: " + ev.fault.faultString;
                              public function saveVisitor():void {
                                        saveService.addUpdateVisitor(visitor);
                              private function creationCompleteHandler():void {
                                        init();
                                        PopUpManager.centerPopUp(this);
                                        resetFocus();
                              private function resetFocus():void {
                                        focusManager.setFocus(vTypeField);
                              public function validateForm(event:Event):void  {
                                        focussedFormControl = event.target as DisplayObject;   
                                        formIsValid = true;
                                        // Check if form is empty
                                        formIsEmpty = (vTypeField.text == "" && vPurposeField.text == "" && vNameField.text == "" && vAddressField.text == "" && cPersonField.text == "" && cAddressField.text == "");
                                        validate(vTypeValidator);               
                                        validate(vPurposeValidator);
                                        validate(vNameValidator);
                                        validate(vAddressValidator);
                                        validate(cPersonValidator);
                                        validate(cAddressValidator);
                              private function validate(validator:Validator):Boolean {
                                        var validatorSource:DisplayObject = validator.source as DisplayObject;
                                        var suppressEvents:Boolean = (validatorSource != focussedFormControl);
                                        var event:ValidationResultEvent = validator.validate(null, suppressEvents);
                                        var currentControlIsValid:Boolean = (event.type == ValidationResultEvent.VALID);
                                        formIsValid = formIsValid && currentControlIsValid;
                                        return currentControlIsValid;
                              private function clearFormHandler():void {
                                        // Clear all input fields.
                                        vTypeField.text = "";
                                        vPurposeField.text = "";
                                        vNameField.text = "";
                                        vAddressField.text = "";
                                        cPersonField.text = "";
                                        cAddressField.text = "";
                                        message = "";
                                        // Clear validation error messages.
                                        vTypeField.errorString = "";
                                        vPurposeField.errorString = "";
                                        vNameField.errorString = "";
                                        vAddressField.errorString = "";
                                        cPersonField.errorString = "";
                                        cAddressField.errorString = "";
                                        formIsEmpty = true;
                                        formIsValid = false;
                                        resetFocus();
                              private function init():void {
                              webCam = new WebCam(97,97);
                              var ref:UIComponent = new UIComponent();
                              preview.removeAllChildren();
                              preview.addChild(ref);
                              ref.addChild(webCam);
                              private function takeSnapshot():void {
                              imageViewer.visible = true;
                              imageViewer.width = preview.width;
                              imageViewer.height = preview.height;
                              var uiComponent : UIComponent = new UIComponent();
                              uiComponent.width = webCam.width;
                              uiComponent.height = webCam.height;
                              var photoData:Bitmap = webCam.getSnapshot();
                              var photoBitmap:BitmapData = photoData.bitmapData;
                              uiComponent.addChild(photoData);
                              imageViewer.removeAllChildren();
                              imageViewer.addChild(uiComponent);
                              private function uploadSnapshot():void
                                        if (imageViewer.getChildren().length > 0)
                                                  var uic:UIComponent = imageViewer.getChildAt(0) as UIComponent;
                                                  var bitmap:Bitmap = uic.getChildAt(0) as Bitmap;
                                                  var jpgEncoder:JPEGEncoder = new JPEGEncoder(75);
                                                  var jpgBytes:ByteArray = jpgEncoder.encode(bitmap.bitmapData);
                              private function deleteSnapshot():void
                                        imageViewer.removeAllChildren();
                    ]]>
                    </mx:Script>
          <mx:StringValidator id="vTypeValidator"          source="{vTypeField}"          property="text" minLength="2" required="true" />
          <mx:StringValidator id="vPurposeValidator" source="{vPurposeField}"          property="text" minLength="2" required="true" />
          <mx:StringValidator id="vNameValidator"          source="{vNameField}"          property="text" minLength="2" required="true" />
          <mx:StringValidator id="vAddressValidator"          source="{vAddressField}"          property="text" minLength="5" required="true" />
          <mx:StringValidator id="cPersonValidator" source="{cPersonField}"          property="text" minLength="2" required="true" />
          <mx:StringValidator id="cAddressValidator"          source="{cAddressField}"          property="text" minLength="5" required="true" />
          <mx:Grid width="575" height="211">
                    <mx:GridRow width="575" height="211">
                              <mx:GridItem width="301" height="235">
                                        <mx:Form width="301" height="208">
                                                  <mx:FormItem label="Visitor's Type">
                                                            <mx:ComboBox id="vTypeField" text="{visitor.vType}" change="validateForm(event);" editable="true">
                                                                      <mx:Array>
                                                                                <mx:String></mx:String>
                                                                                <mx:String>Contractor</mx:String>
                                                                                <mx:String>Supplier</mx:String>
                                                                                <mx:String>Transporter</mx:String>
                                                                                <mx:String>Plant</mx:String>
                                                                                <mx:String>Non-Plant</mx:String>
                                                                      </mx:Array>
                                                            </mx:ComboBox>
                                                  </mx:FormItem>
                                                  <mx:FormItem label="Visit Purpose">
                                                            <mx:ComboBox id="vPurposeField" text="{visitor.vPurpose}" change="validateForm(event);" editable="true">
                                                                      <mx:Array>
                                                                                <mx:String></mx:String>
                                                                                <mx:String>Official</mx:String>
                                                                                <mx:String>Personal</mx:String>
                                                                      </mx:Array>
                                                            </mx:ComboBox>
                                                  </mx:FormItem>
                                                  <mx:FormItem label="Visitor's Name">
                                                            <mx:TextInput id="vNameField"  text="{visitor.vName}" change="validateForm(event);"/>
                                                  </mx:FormItem>
                                                  <mx:FormItem label="Address">
                                                            <mx:TextInput id="vAddressField"   text="{visitor.vAddress}" change="validateForm(event);"/>
                                                  </mx:FormItem>
                                                  <mx:FormItem label="Contact Person">
                                                            <mx:TextInput id="cPersonField"  text="{visitor.cPerson}" change="validateForm(event);"/>
                                                  </mx:FormItem>
                                                  <mx:FormItem label="Address">
                                                            <mx:TextInput id="cAddressField"  text="{visitor.cAddress}" change="validateForm(event);"/>
                                                  </mx:FormItem>
                                                  </mx:Form>
                              </mx:GridItem>
                              <mx:GridItem width="264" height="193">
                                        <mx:Grid width="241" height="206">
                                                  <mx:GridRow width="100%" height="100%">
                                                            <mx:GridItem width="100%" height="100%" horizontalAlign="center" verticalAlign="middle">
                                                                      <mx:Panel width="100" height="132" title="Snap" id="preview" layout="absolute"/>
                                                            </mx:GridItem>
                                                            <mx:GridItem width="100%" height="100%" horizontalAlign="center" verticalAlign="middle">
                                                                      <mx:Panel width="100" height="132" title="Preview" id="imageViewer"  layout="absolute"/>
                                                            </mx:GridItem>
                                                  </mx:GridRow>
                                                  <mx:GridRow width="100%" height="27" >
                                                            <mx:GridItem width="100%" height="100%" horizontalAlign="center">
                                                                      <mx:Button id="snapshot" x="2" width="106" height="27" label="Snap"
                                                                                              click="takeSnapshot();"/>
                                                            </mx:GridItem>
                                                            <mx:GridItem width="100%" height="100%" horizontalAlign="center">
                                                                      <mx:Button id="deleteButton" x="1" width="106" height="27" label="Delete"
                                                                                              click="deleteSnapshot();"/>
                                                            </mx:GridItem>
                                                  </mx:GridRow>
                                        </mx:Grid>
                              </mx:GridItem>
                    </mx:GridRow>
          </mx:Grid>
          <mx:ControlBar height="40" horizontalAlign="center">
                    <mx:Button label="Save Visitor"          id="submitButton" enabled="{formIsValid}" click="saveVisitor();" />
                    <mx:Button label="Clear form" enabled="{!formIsEmpty}"          click="clearFormHandler();" />
                    <mx:Button label="Cancel" click="PopUpManager.removePopUp(this);"/>
                    <mx:Label width="211" id="state"/>
          </mx:ControlBar>
          <mx:Text text="{message}" fontWeight="bold" width="300"/>
</mx:TitleWindow>
ListVisitors.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel
          xmlns:mx="http://www.adobe.com/2006/mxml"
          xmlns:view="com.visitor.view.*"
          width="100%"
          height="100%"
          title="Visitor Management System - Found {visitorRecords} visitors."
          creationComplete="loadVisitors();">
          <mx:RemoteObject id="loaderService" destination="visitorService" result="handleLoadResult(event)"          fault="handleFault(event)" showBusyCursor="true" />
          <mx:RemoteObject id="deleteService" destination="visitorService" result="handleDeleteResult(event)"          fault="handleFault(event)" showBusyCursor="true" />
          <mx:Script>
                    <![CDATA[
                              import com.visitor.vo.Visitor;
                              import mx.controls.Alert;
                              import mx.managers.PopUpManager;
                              import mx.containers.TitleWindow;
                              import mx.collections.ArrayCollection;
                              import mx.rpc.events.ResultEvent;
                              import mx.rpc.events.FaultEvent;
                              [Bindable]
                              private var message:String;
                              [Bindable]
                              private var visitors:ArrayCollection = new ArrayCollection();
                              [Bindable]
                              private var visitorRecords:int = 0;
                              public function loadVisitors():void {
                                        loaderService.getVisitors();
                              private function deleteVisitor():void {
                                        if(dataGrid.selectedItem != null) {
                                                  var selectedItem:Visitor = dataGrid.selectedItem as Visitor;
                                                  deleteService.deleteVisitor(selectedItem.visitorId);
                              private function createVisitor():void {
                                        var titleWindow:VisitorEntryForm = VisitorEntryForm(PopUpManager.createPopUp(this, VisitorEntryForm, true));
                                        titleWindow.setStyle("borderAlpha", 0.9);
                                        titleWindow.formIsEmpty = true;
                              private function updateVisitor():void {
                                        var titleWindow:VisitorEntryForm = VisitorEntryForm(PopUpManager.createPopUp(this, VisitorEntryForm, true));
                                        titleWindow.setStyle("borderAlpha", 0.9);
                                        titleWindow.visitor = dataGrid.selectedItem as Visitor;
                                        titleWindow.formIsEmpty = false;
                              private function handleLoadResult(ev:ResultEvent):void {
                                        visitors = ev.result as ArrayCollection;
                                        visitorRecords = visitors.length;
                              private function handleDeleteResult(ev:ResultEvent):void {
                                        Alert.show("The visitor has been deleted.", "Information", Alert.OK, null, null, null, Alert.OK);
                                        loadVisitors();
                              private function handleFault(ev:FaultEvent):void {
                                        message = "Error: "
                                                  + ev.fault.faultCode + " - "
                                                  + ev.fault.faultDetail + " - "
                                                  + ev.fault.faultString;
                    ]]>
          </mx:Script>
          <mx:VBox width="100%" height="100%">
                    <mx:Label text="{message}" fontWeight="bold" includeInLayout="false" />
                    <mx:DataGrid
                              id="dataGrid"
                              width="100%"
                              height="100%"
                              dataProvider="{visitors}"
                              doubleClickEnabled="true"
                              doubleClick="updateVisitor()" >
                              <mx:columns>
                                        <mx:DataGridColumn dataField="visitorId"          headerText="Visitor ID" width="100"/>
                                        <mx:DataGridColumn dataField="vType"                    headerText="Visitor's Type" />
                                        <mx:DataGridColumn dataField="vPurpose"           headerText="Visit Purpose" />
                                        <mx:DataGridColumn dataField="vName"                     headerText="Visitor's Name" />
                                        <mx:DataGridColumn dataField="vAddress"                    headerText="Visitor's Address" />
                                        <mx:DataGridColumn dataField="cPerson"                     headerText="Contact Person" />
                                        <mx:DataGridColumn dataField="cAddress"                    headerText="Contact Address" />
                                        <mx:DataGridColumn dataField="timeIn"                     headerText="Time-In" />
                                        <mx:DataGridColumn dataField="timeOut"                     headerText="Time-Out" />
                                        <mx:DataGridColumn dataField="vPhoto"                     headerText="Visitor's Photo" />
                              </mx:columns>
                    </mx:DataGrid>
                    <mx:ControlBar horizontalAlign="center">
                              <mx:Button label="Create Visitor"          click="createVisitor()"          toolTip="Create a new visitor and store it in the database." />
                              <mx:Button label="Update Visitor"          click="updateVisitor()"           enabled="{dataGrid.selectedItem}" toolTip="Update an existing database visitor." />
                              <mx:Button label="Delete Visitor"          click="deleteVisitor()"          enabled="{dataGrid.selectedItem}" toolTip="Delete the visitor from the database." />
                              <mx:Button label="Reload Data"                    click="loadVisitors()"           toolTip="Reload the visitor list from the database." />
                    </mx:ControlBar>
          </mx:VBox>
</mx:Panel>
Visitor.as
package com.visitor.vo
          import mx.controls.Image;
          import spark.primitives.BitmapImage;
          [Bindable]
          [RemoteClass(alias="com.visitor.Visitor")]
          public class Visitor
                    public function Visitor()
                    public var visitorId:Number;
                    public var vType:String;
                    public var vPurpose:String;
                    public var vName:String;
                    public var vAddress:String;
                    public var cPerson:String;
                    public var cAddress:String;
                    public var timeIn:Date;
                    public var timeOut:Date;
                   public var vPhoto: Image;
Visitor.java
package com.visitor;
import java.sql.Blob;
import java.sql.Timestamp;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import org.hibernate.annotations.Index;
@Entity
@Table(name = "visitors")
@NamedQueries( {
                    @NamedQuery(name = "visitors.findAll", query = "from Visitor"),
                    @NamedQuery(name = "visitors.byId", query = "select v from Visitor v where v.visitorId= :visitorId") })
public class Visitor {
          @Id
          @GeneratedValue(strategy = GenerationType.AUTO)
          @Column(name = "visitorId", nullable = false)
          private Long visitorId;
          @Basic
          @Index(name = "vType_idx_1")
          @Column(name = "vType", nullable = true, unique = false)
          private String vType;
          @Basic
          @Column(name = "vPurpose", nullable = true, unique = false)
          private String vPurpose;
          @Basic
          @Column(name = "vName", nullable = true, unique = false)
          private String vName;
          @Basic
          @Column(name = "vAddress", nullable = true, unique = false)
          private String vAddress;
          @Basic
          @Column(name = "cPerson", nullable = true, unique = false)
          private String cPerson;
          @Basic
          @Column(name = "cAddress", nullable = true, unique = false)
          private String cAddress;
          @Basic
          @Column(name = "timeIn", nullable = false, unique = false)
          private Timestamp timeIn;
          @Basic
          @Column(name = "timeOut", nullable = true, unique = false)
          private Timestamp timeOut;
          @Basic
          @Column(name = "vPhoto", nullable = true, unique = false)
          private Blob vPhoto;
          public Visitor() {
                    super();
          public Long getVisitorId() {
                    return visitorId;
          public void setVisitorId(Long visitorId) {
                    this.visitorId = visitorId;
          public String getvType() {
                    return vType;
          public void setvType(String vType) {
                    this.vType = vType;
          public String getvPurpose() {
                    return vPurpose;
          public void setvPurpose(String vPurpose) {
                    this.vPurpose = vPurpose;
          public String getvName() {
                    return vName;
          public void setvName(String vName) {
                    this.vName = vName;
          public String getvAddress() {
                    return vAddress;
          public void setvAddress(String vAddress) {
                    this.vAddress = vAddress;
          public String getcPerson() {
                    return cPerson;
          public void setcPerson(String cPerson) {
                    this.cPerson = cPerson;
          public String getcAddress() {
                    return cAddress;
          public void setcAddress(String cAddress) {
                    this.cAddress = cAddress;
          public Timestamp getTimeIn() {
                    return timeIn;
          public void setTimeIn(Timestamp timeIn) {
                    this.timeIn = timeIn;
          public Timestamp getTimeOut() {
                    return timeOut;
          public void setTimeOut(Timestamp timeOut) {
                    this.timeOut = timeOut;
          public Blob getvPhoto() {
                    return vPhoto;
          public void setvPhoto(Blob vPhoto) {
                    this.vPhoto = vPhoto;
VisitorService.java
package com.visitor;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import javax.persistence.Query;
import org.apache.log4j.Logger;
public class VisitorService {
          private static final String PERSISTENCE_UNIT = "visitor_db";
          private static Logger logger = Logger.getLogger(VisitorService.class);
          public VisitorService() {
                    super();
          public List<Visitor> getvisitors() {
                    logger.debug("** getVisitors called...");
                    EntityManagerFactory entityManagerFactory = Persistence
                                        .createEntityManagerFactory(PERSISTENCE_UNIT);
                    EntityManager em = entityManagerFactory.createEntityManager();
                    Query findAllQuery = em.createNamedQuery("visitors.findAll");
                    List<Visitor> visitors = findAllQuery.getResultList();
                    if (visitors != null)
                              logger.debug("** Found " + visitors.size() + " records:");
                    return visitors;
          public void addUpdateVisitor(Visitor visitor) throws Exception {
                    logger.debug("** addUpdateVisitor called...");
                    EntityManagerFactory emf = Persistence
                                        .createEntityManagerFactory(PERSISTENCE_UNIT);
                    EntityManager em = emf.createEntityManager();
                    // When passing Boolean and Number values from the Flash client to a
                    // Java object, Java interprets null values as the default values for
                    // primitive types; for example, 0 for double, float, long, int, short,
                    // byte.
                    if (visitor.getVisitorId() == null          || visitor.getVisitorId() == 0) {
                              // New consultant is created
                              visitor.setVisitorId(null);
                              visitor.setTimeIn(new Timestamp(new Date().getTime()));
                    } else {
                              visitor.setTimeOut(new Timestamp(new Date().getTime()));
                              // Existing consultant is updated - do nothing.
                    EntityTransaction tx = em.getTransaction();
                    tx.begin();
                    try {
                              em.merge(visitor);
                              tx.commit();
                    } catch (Exception e) {
                              logger.error("** Error: " + e.getMessage());
                              tx.rollback();
                              throw new Exception(e.getMessage());
                    } finally {
                              logger.info("** Closing Entity Manager.");
                              em.close();
          public void deleteVisitor(Long visitorId) {
                    logger.debug("** deleteVisitor called...");
                    EntityManagerFactory emf = Persistence
                                        .createEntityManagerFactory(PERSISTENCE_UNIT);
                    EntityManager em = emf.createEntityManager();
                    Query q = em.createNamedQuery("visitors.byId");
                    q.setParameter("visitorId", visitorId);
                    Visitor visitor = (Visitor) q.getSingleResult();
                    if (visitor != null) {
                              EntityTransaction tx = em.getTransaction();
                              tx.begin();
                              try {
                                        em.remove(visitor);
                                        tx.commit();
                              } catch (Exception e) {
                                        logger.error("** Error: " + e.getMessage());
                                        tx.rollback();
                              } finally {
                                        logger.info("** Closing Entity Manager.");
                                        em.close();
remoting-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<service id="remoting-service" class="flex.messaging.services.RemotingService">
          <adapters>
                    <adapter-definition id="java-object"
                              class="flex.messaging.services.remoting.adapters.JavaAdapter"
                              default="true" />
          </adapters>
          <default-channels>
                    <channel ref="my-amf" />
          </default-channels>
          <!-- ADC Demo application -->
          <destination id="visitorService">
                    <properties>
                              <source>com.visitor.VisitorService</source>
                    </properties>
          </destination>
</service>

Similar Messages

  • How to store an image into database table

    Hi
    Can anyone tell me the way, how to store an image into database table.

    Hello,
    May be this thread will help you in your requirement.
    [FM for uploading Image to SAP;
    Thanks,
    Jayant

  • How to insert an image into mysql

    welcome to all,
    can any one tell how to insert an image into mysql database(BLOB). it is urgent.
    regards

    welcome to all,
    can any one tell how to insert an image into mysql database(BLOB). it is urgent.
    regards

  • How to store jpeg images in SQL server using NI database Connectivity Toolset. Can anyone please help me in this regard.

    Please tell how to store jpeg images in SQL Server using NI Database Connectivity Toolset.

    http://www.w3schools.com/sql/sql_datatypes.asp
    You setup a field as BLOB and store the binary of the picture there. Depending on the database it can be called differently as you can see in the link, in SQL server there's even a Image datatype.
    /Y
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

  • How to store the images in Oracle?

    Hi,
    I am a new developer, trying to find out how to store the images in Oracle. Is there anyway that I can store the images in Oracle and insert them into my html file?
    Thanks!
    Sarah

    There is a simple image example available from OTN.
    From the OTN main page, go to Products --> interMedia --> Sample Code. The name of the example is "Load rich media content with a browser."
    This example loads and retrieves an image from an Oracle8i database through a web page using the Oracle interMedia Web Agent.
    Hope this helps.
    null

  • How to update transaction data automatically into MySQL database using PI

    Dear All,
    With reference to subject matter I want a sincere advice regarding how to update transaction data automatically into MySQL database using PI. Is there any link available where I can get step-by-step process.
    Ex: I have a MYSQL database in my organization. Whenever a delivery created in SAP some fields like DO Number, DO quantity, SO/STO number should get updated in MYSQL database automatically.
    This scenario is related to updation of transactional data into MYSQL DB and I want your suggestions pertaining to same issue.
    Thanks and Regards,
    Chandra Sekhar

    Hi .
    Develop a sceanrio between SAP to Database system,When the data updates in SAP Tables read the data and update it in DATA Base using JDBC adapter,but there will be some delay in updating data in MySQL.
    serach in sdn for IDOC-TOJDBC sceannario,many documents available for the same.
    Regards,
    Raja Sekhar

  • How to store the images in tables

    how to store the images in tables .what is the use of "clob ,blob"

    Using with the CLOB or BLOB, you can store the images in the table.
    Srini C

  • How to store photo images and thumbimpressions in oracle 10g database

    Hi all
    I have an web application running in Oracle 10g rel 1 database server in RHEL3. It has application server with forms and j2ee component as middle tier. I need to store centrally photo images and thumb impressions and use it in our application without any overhead on retrieval and performance of web application. what will be optimized method of storage of photo and thumb impressions. Awaiting your valuable suggestions.
    Regards
    Vijay Kumar

    Hi Vijay,
    How to store photo images and thumbimpressions in oracle 10g database I have working code here for storing photos in Oracle tables that you may find useful:
    http://www.dba-oracle.com/t_storing_insert_photo_pictures_tables.htm
    Hope this helps . . .
    Donald K. Burleson
    Oracle Press author
    Author of "Oracle Tuning: The Definitive Reference"
    http://www.rampant-books.com/book_2005_1_awr_proactive_tuning.htm

  • How to convert jpeg images into video file of any ext using JMF

    I want to convert the Jpeg files into video clip with the help of JMF
    any one can help me?
    Plz reply me at [email protected]
    or [email protected]

    I'm not sure of his/her reasoning behind this, but I have yet to find a way to record video with mmapi on j2me. So with that restriction, I can see how one could make it so that it just records a lot of jpegs, and then makes it a movie.
    I would be interested finding a workaround for this too. Either if someone would explain how to record video with mmapi or how to make recorded images into a video. Thanks!

  • How to store xml data into file in xml format through java program?

    HI Friends,
    Please let me know
    How to store xml data into file in xml format through java program?
    thanks......
    can discuss further at messenger.....
    Avanish Kumar Singh
    Software Engineer,
    Samsung India Development Center,
    Bangalore--560001.
    [email protected]

    Hi i need to write the data from an XML file to a Microsoft SQL SErver database!
    i got a piece of code from the net which allows me to parse th file:
    import java.io.IOException;
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    import org.apache.xerces.parsers.SAXParser;
    import java.lang.*;
    public class MySaxParser extends DefaultHandler
    private static int INDENT = 4;
    private static String attList = "";
    public static void main(String[] argv)
    if (argv.length != 1)
    System.out.println("Usage: java MySaxParser [URI]");
    System.exit(0);
    String uri = argv[0];
    try
    XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
    MySaxParser MySaxParserInstance = new MySaxParser();
    parser.setContentHandler(MySaxParserInstance);
    parser.parse(uri);
    catch(IOException ioe)
    ioe.printStackTrace();
    catch(SAXException saxe)
    saxe.printStackTrace();
    private int idx = 0;
    public void characters(char[] ch, int start, int length)
    throws SAXException
    String s = new String(ch, start, length);
    if (ch[0] == '\n')
    return;
    System.out.println(getIndent() + " Value: " + s);
    public void endDocument() throws SAXException
    idx -= INDENT;
    public void endElement(String uri, String localName, String qName) throws SAXException
    if (!attList.equals(""))
    System.out.println(getIndent() + " Attributes: " + attList);
    attList = "";
    System.out.println(getIndent() + "end document");
    idx -= INDENT;
    public void startDocument() throws SAXException
    idx += INDENT;
    public void startElement(String uri,
    String localName,
    String qName,
    Attributes attributes) throws SAXException
    idx += INDENT;
    System.out.println('\n' + getIndent() + "start element: " + localName);
    if (localName.compareTo("Machine") == 0)
    System.out.println("YES");
    if (attributes.getLength() > 0)
    idx += INDENT;
    for (int i = 0; i < attributes.getLength(); i++)
    attList = attList + attributes.getLocalName(i) + " = " + attributes.getValue(i);
    if (i < (attributes.getLength() - 1))
    attList = attList + ", ";
    idx-= INDENT;
    private String getIndent()
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < idx; i++)
    sb.append(" ");
    return sb.toString();
    }// END PRGM
    Now , am not a very good Java DEv. and i need to find a soln. to this prob within 1 week.
    The next step is to write the data to the DB.
    Am sending an example of my file:
    <Start>
    <Machine>
    <Hostname> IPCServer </Hostname>
    <HostID> 80c04499 </HostID>
    <MachineType> sun4u [ID 466748 kern.info] Sun Ultra 5/10 UPA/PCI (UltraSPARC-IIi 360MHz) </MachineType>
    <CPU> UltraSPARC-IIi at 360 MHz </CPU>
    <Memory> RAM : 512 MB </Memory>
    <HostAdapter>
    <HA> kern.info] </HA>
    </HostAdapter>
    <Harddisks>
    <HD>
    <HD1> c0t0d0 ctrl kern.info] target 0 lun 0 </HD1>
    <HD2> ST38420A 8.2 GB </HD2>
    </HD>
    </Harddisks>
    <GraphicCard> m64B : PCI PGX 8-bit +Accel. </GraphicCard>
    <NetworkType> hme0 : Fast-Ethernet </NetworkType>
    <EthernetAddress> 09:00:30:C1:34:90 </EthernetAddress>
    <IPAddress> 149.51.23.140 </IPAddress>
    </Machine>
    </Start>
    Note that i can have more than 1 machines (meaning that i have to loop thru the file to be able to write to the DB)
    Cal u tellme what to do!
    Even better- do u have a piece of code that will help me understand and implement the database writing portion?
    I badly need help here.
    THANX

  • Guys, i want to ask on how to resize the images into 1200 pixels wide?

    Guys, i want to ask on how to resize the images into 1200 pixels wide, how to do it? and what are the step by steps on doing that? thank you!!!

    See this link: http://forums.adobe.com/docs/DOC-3691

  • How to load an image into blob in a custom form

    Hi all!
    is there some docs or how to, load am image into a database blob in a custom apps form.
    The general idea is that the user has to browse the local machine find the image, and load the image in a database blob and also in the custom form and then finally saving the image as blob.
    Thanks in advance
    Soni

    If this helps:
    Re: Custom form: Take a file name input from user.
    Thanks
    Nagamohan

  • How to store double quote into a string?

    How to store double quote into a string?
    What I mean is:
    suppose I want to save the following sentence into string s:
    What is the syntax?
    Thanks a lot!

    String s = "<a href=\"../jsp/Logout.jsp\">"
    check out this page
    http://java.sun.com/docs/books/tutorial/index.html
    Hope this helps

  • How to export dynamic images into pdf

    Hi,
    I need to export a image into PDF which we are getting it from DBase. This returns me the image as BLOB and this we are putting it in between the xml tags. I am passing the xml to xsl-fo. While i tried to export the xml data into pdf using xsl-fo, the content is getting exported into pdf but not the image. I am using FOP, and i have added fop.jar, batik.jar, avalon-xx.jar, jai_codec.jar and jai_core.jar to my class path. I am putting my sample xsl and xml here.
    xml:
    <RTFDrugReport>
    <ImagePath>http://www.thomson-pharma.com/tp/images</ImagePath>
    <NewsEdge>
    <NewsItem>
    <StoryId><![CDATA[200705223600.15_2774000daba43be0]]></StoryId>
    <HeadlineText><![CDATA[NeuroLogica's CereTom Supplies On Site Post-Fight Brain CT During De  La Hoya-Mayweather Weekend]]></HeadlineText>
    <ItemTime><![CDATA[05/23/2007 03:22:24 AM EDT]]></ItemTime>
    </NewsItem>
    </NewsEdge>
    </RTFDrugReport>
    xsl:
    <fo:static-content flow-name="xsl-region-before">
    <fo:block font-family="Helvetica" font-size="14pt" text-align="left" white-space-collapse="false">
    <xsl:variable name="imageName" select="concat(//ImagePath,'/logo_thomson_pharma.png')"/>
    <fo:external-graphic src="'{$imageName}'"/>first
    <fo:external-graphic src="url('{$imageName}')"/>second
    <xsl:value-of select="'{$imageName}'"/>thrid
    <fo:external-graphic src="'{$imageName}'" content-width="100mm" content-height="100mm"/>fourth
    <fo:external-graphic src="'{$imageName}'" content-width="100mm" content-height="100mm"/>fifth
    <fo:instream-foreign-object src='url("///file:/D:/Customization/collage.jpg")' height="3cm" width="3cm"/>
    </fo:block>
    </fo:static-content>
    Any help would be appreciated.

    hi,
    all the UI elements in the adobe form are generally connected to your web-dynpro Context.
    whatever you type in the online adobe form is reflected in the respective context attributes of the dynpro Context of the view where "ur Interactive form UI element is".
    that means you can yourself fill the contents of ur interactive form by working on the get/set methods of the context attributes.
    Likewise you can clear the form by setting all context attributes to blank eg ""
    <b>interactive form has two imp properties:-</b>
    <b>*dataSource</b>
    data source points to the node all whose context attributes will be made available in the interactive form
    <b>*pdfsource</b>
    points to the context attribute which will hold the pdf.
    note that the type of this pdfSorce attribute will be binary.
    if you still have doubts.
    give me your gmail mail id. i 'll send a tutorial.
    with regards,
    -ag.

  • How do I convert .pdf into searchable OCR using Adobe Acrobat Capture 3.0?

    How do I convert .pdf into searchable OCR using Adobe Acrobat
    Capture 3.0?
    Our division is digitizing it's files, and we've been using
    Adobe Acrobat 5.0 (2). We've 'scanned-in' several hundred
    documents, but they have been saved as .pdf files (which are
    currently not 'searchable', as they are only scanned images).
    We just received the Adobe Acrobat Capture 3.0 program, and
    we were told that we would be able to scan-in any new documents and
    save them both as .pdf and OCR documents (Optical Character
    Recognition). Therefore, we were told, we would be able to search
    through the body of the document, using OCR, and not just through
    the document filename, as we had been doing before.
    HOWEVER, we don't know how to use this new OCRing program.
    Also, we don't know how to convert the .pdf documents which we've
    already scanned into OCR recognizable documents.
    Is someone able to assist us here in this forum?
    Merci beaucoup / Shokran jazilan / Thank you very much!
    - Michael Kim Jamal Riegelman
    United Nations Headquarters
    Department of Peacekeeping Operations
    Europe and Latin America Division
    Office: (917) 367.9186
    Email: [email protected]

    Hi Michael
    Unfortunately I believe you have posted your issue in the
    wrong forum. I believe you are looking for the forum linked below.
    http://www.adobeforums.com/cgi-bin/webx/.ef7cbdf/
    You might try re-posting your issue there.
    Cheers and good luck! Rick

Maybe you are looking for

  • Artwork missing... Leopard? or new iMac problem?

    Hi, I recently moved all of my music to my new iMac. Then I discovered that not all of my artwork moved over. Many of the albums that had artwork no longer have it. What's even more strange is that my iPod and iPhone have some of the missing artwork,

  • Assign sales document to material document

    Hello experts, I had recieved goods with movement type 501. Now I am trying to do roll conversion for this material document no. For this I am using BAPI '/AFS/BAPI_GOODSMVT_CREATE' which is returning message type 'E' as 'Enter a sales order for spec

  • Linkage between idoc fields with application tables

    dear sir / madam  , i want to know the post the KASSIERER     1000000001 CSHNAME     Cash Customer  segment name E1WPB01 of basic type WPUBON01 message type WPUBON into the vbrk header table .as the fields of segments KUNDNR moves to kunrg of vbrk .w

  • JSF - Tomcats Realm - General Question

    Hi @ ll, I've written a wep app in JSF. Evererything works fine. Also the autentification by Tomcats JDBC Realm. My problem is. only the login is not written in JSF, cause every form get id prefix. I know its "normal" in in JSF. But Tomcat expect a s

  • Disabling Keep Alive

    We are using GWT with Glassfish and Sun Web server. We're encountering occassional problems causing the servlet to fail with "Client did not send xxxx bytes" exception. I read in another post elsewhere that people have solved this problem in Glassfis