0

Is it possible to connect to a remote database from my flex4.5 Mobile application ?

I am trying to develop a flex 4.5 mobile application and my data is in Oracle Database. I choose Java as my back end technology. How can I call the java services from flex. I wanted my mobile application to run on iOS devices.

Radha
  • 121
  • 2
  • 13

1 Answers1

0

Yes. You can connect to any database, as long as that database can be connected to via php or Java (possibly other server-side languages as well). It uses a remote call, similiar to Ajax (but faster).

You can use a RemoteObject component. RemoteObject components use the AMF protocol to send and receive data, while WebService and HTTPService components use the HTTP protocol. AMF is significantly faster than HTTP.

On the Flex Side:

<mx:RemoteObject id="Hello" destination="roDest"> 
    <mx:method name="getHelloData"/> 
</mx:RemoteObject>

On the Java side: ...

public void getHelloData() { 
    try{ 
        InitialContext ctx = new InitialContext(); 
        Object obj = ctx.lookup("/Hello"); 
        HelloHome ejbHome = (HelloHome) 
        PortableRemoteObject.narrow(obj, HelloHome.class); 
        HelloObject ejbObject = ejbHome.create(); 
        String message = ejbObject.sayHello(); 
        } 
    catch (Exception e); 
    } 

...

The code examples were taken from:

http://help.adobe.com/en_US/flex/accessingdata/WS2db454920e96a9e51e63e3d11c0bf69084-7fda.html#WS2db454920e96a9e51e63e3d11c0bf66651-7fd7

Cymbals
  • 1,164
  • 1
  • 13
  • 26
  • Thanks for your response. In a Flex web application yes I did in similar way but I am not getting the way How to do it in Mobile application. DO i need 2 separate projects in my flash buiilder one for the Java service and second for the Flash Mobiel application ? Or can I have Java code and Flex code in the same project and How to call the Java service using the Flash Mobiel componenents ? Thanks. – Radha Oct 27 '11 at 18:36
  • See this url for details on the setup: http://help.adobe.com/en_US/flashbuilder/using/WSe4e4b720da9dedb5-1a92eab212e75b9d8b2-7f9d.html – Cymbals Oct 28 '11 at 13:24
  • also: http://www.jamesward.com/2011/03/08/integrating-flex-and-java-ee-with-jboss/ – Cymbals Oct 28 '11 at 15:18