0

I've been developing GWT applications for some time , This is my first time creating an app in GWT/Phonegap with mgwt.

I just migrated my old GWT project to phoneGap ,everything's fine , i can see my running GWT app on mobile.In my GWT website , I was using MySQL,Hibernate

Now I'm confused what i need to get connected my this Mobile App to a database. Can i use the same sql, hibernate..

Or i need something else, and writing all the queries again for mobile?

I found this during my search ..do i need to use this one..

https://code.google.com/p/gwt-localstorage-db/wiki/UsingTheApi


I was connecting to db in my gwt web app like this in my applicationcontext.xml class

             <?xml version="1.0" encoding="UTF-8"?>

     <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"
default-lazy-init="true">

<!-- Datasource for LOCAL database connection -->

<bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mysql://localhost/leave" />
    <property name="username" value="root" />
    <property name="password" value="" />

</bean>

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="annotatedClasses">
        <list>
            <value>com.leavemanagement.shared.User</value>


        </list>
    </property>
</bean>
<bean id="ManagerExams" class="com.leavemanagement.database.MySQLRdbHelper">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>

junaidp
  • 10,801
  • 29
  • 89
  • 137

2 Answers2

0

@junaidp,
I don't know what GWT is. Java beans are not available via phonegap, but Java code can be added via plugins. You can create private plugins.

For your task, you need to use a plugin to access your DB. This is your search link for plugins. You will want to use "localstorage" for simple storage. For more complex storage on the device you have "indexDB" and "sqlite". If you need more storage, use on-line (internet) storage via a REST API - like parse.com or firebase.com.
-Jesse

  • @junaldp, the information at gwtproject.org indicates it has a phonegap. it is about half way down on this webpage: http://www.m-gwt.com/ the documentation is https://github.com/mgwt/mgwt/wiki It claims phonegap support, but I was not able to find any easily. Nor am I able to tell you what it does. What does it do? What are you using this for? –  Aug 15 '15 at 04:52
  • this link is mgwt , Mobile GWT , it just provides interface for mobile Applications developed in GWT , provide some widgets etc .. if we need to run GWT applications on Mobile , we need PhoneGap . we just create a standard PhoneGapAndroid Project and in its www folder we put the compiled output of our GWT project ..I put my GWT project there and its all working , but in my that GWT application i am using MySQL with Hibernate , So that Database connectivity etc is not working in mobile.Thats what i am trying to acheive – junaidp Aug 15 '15 at 05:37
0

@junaidp Wait... I think you are saying that you are the creator/developer/programmer behind GWT for phonegap. Let me assume that for a moment. If so, my original advice does NOT change. However, you are asking for connectivity architecture. There is a dozen ways to do this. At minimum you'll need these pieces.

  1. A plugin that runs on phonegap. It has a Javascript interface, then native code that use the network available to it to send data to the server.
  2. A CGI or equivalent on the server. However, the modern approach is to use a REST Interface.
  3. The connect between the two would likely use JQuery or some other AJAX technology. The transport could also be Websocket, but that has overhead issues.

Another design item is security. It would be best not to run any SQL scripts from the mobile device, otherwise this would be subject SQL-injection attacks

If you need anything else, this is the wrong forum. I suggest moving this discussion to Google Groups for Phonegap.