Access to GWT database without RPC

I am using GWT for a web application and I need to access mySql database. There will be only one client (the application is used on the local iPad). Is there a way to access a database without RPC? I am looking for the opportunity to access the database directly.

Thanks!

+1
source share
5 answers

There are 2.5 reasons why you cannot use gwt for direct access to MySQL.

Reason number 1. GWT compiled in Javascript. You need to open the socket on the database server. GWT does not allow you to open a socket. In fact, not a single undisclosed browser (before html5) can open a socket. But you can open the socket using a flash script or HTML 5 javascript.

Reason # 2. Well, let's say you used HTML5 sockets. And you spent 6 months writing Javascript in a JDBC connection. But your websocket will still need to access the servlet on the server, which will help your web site establish a permanent connection - and mysql will not be able to perform such a setup.

Reason No. 3. SLD restriction - SOP: (Policy of the same origin at the second level level) The standard browser restricts its pages only to the ability to request and include content from one second level domain (SLD) as the server that provided this page to the browser. Top-level domains (and the upper levels are one and a half) - such as .com, .org, .net, .me.us or .co.uk. Thus, domain names such as google.com, fbi.gov, mit.edu are second-level domains. Although, mail.google.com will be a third level domain. Therefore, GWT will work only within the framework of SLD. Your web server should also be accessible on the same SLD as your mysql server.

SLD-SOP's requirement and tunneling is to close a security hole that would allow any tom-rick-or-mary to log into your system in your browser. Tunneling is always necessary to connect the browser to a server other than the http server. Tunneling is when a browser uses a web server like yenta (Yiddish for busy-body / go-between / match-maker) to go to another server.

You have no choice but to use the GWT-RPC. Perhaps you do not want to use RPC, then you can use RequestBuilder or Script -Include or RequestFactory. But all of them are still diverse for tunneling. http://h2g2java.blessedgeek.com/2011/06/gwt-requestbuilder-vs-rpc-vs-script.html .

There is one reason why you can connect to the database server from your gwt client: The database server must start the httpd connection mechanism. That is, your gwt application will access the db server via http. I do not know which relational database has access to http. Most likely you will have to request xml or json.

However, the company I worked with created its own http service to allow "direct" access to the client. "direct" is wrong because we used tomcat. This is subtle tunneling. Any company with a database that offers "direct" http access still tunnels. Tunneling - Do Not Avoid This.

You can increase the browser using Flash and write a Flash application instead of using GWT. If direct access is so important to you, you will have to give up GWT and develop in Flash and run the httpd engine for your database server.

+3
source

GWT is ultimately Javascript. As noted in are JavaScript bindings for MySQL? There is currently no access to MySQL from Javascript.

Therefore, you cannot access it from the GWT client code.

+2
source

AFAIK this is impossible, and even if it were, it would be a very bad idea. Do you really need a database? Perhaps something like gwt-client-storage would be more appropriate.

EDIT

Your database would be public and open to any attacks.

EDIT 2

It might even be a better solution, as it offers support for accessing the HTML5 database API and is designed for iPhone / iPad.

gwt-mobile-webkit

+1
source

If you were even successful in this, in short, running CTRL + U in a browser would make your database name, username, password, table names, etc. visible ... And done, any developer with curiosity knows your code has a way to hack anything and everything on your server.

0
source

I think this is impossible, I mean, if you want all your data to be stored in the database. I mean, GWT is compiled in javascript and javascript is executed on the client (usually a web browser).

If you want to access data stored somewhere (some kind of medium) on the server, then you have no option except RPC. If I were you, I would stop thinking about the client-server paradigm (GWT was designed with this in mind). Perhaps some embedded databases, such as H2, then support connections through JDBC.

0
source

Source: https://habr.com/ru/post/1445536/


All Articles