Proper way for Javascript to read MySQL data through Java - javascript

I am now learning while developing my Java web app using JSF, and I was asked to study on using Javascript to create datatable/report dynamically and present it via .html/.xhtml. I am required to use Datatables.net to produce the table. The backend process is using Java instead of Php. Since it is so rare to use this method, I got no idea on this. My thought so far is:
MySQL data --convert to (processed by Java code)--> Json --read by-> Javascript
How do I process the SQL data? Can I directly run the query inside Java like:
SELECT
CONCAT("[",
GROUP_CONCAT(
CONCAT("{name:'",NAME,"'"),
CONCAT("email:'",email,"'"),
CONCAT(",address:'",address,"'}")
)
,"]") AS JSON FROM customer
If so, how do I parse the data out and make sure Javascript will read it?
The another way I found is to use some library like Gson or something similar.
Explanations or examples about this issue is much appreciated.

Related

implementation search function

I am developping a client side application with HTML5
my datas (only text data) are stored in my file JSON (70 Mega).
I want to implement a function to search all occurences in my data file.
Does exists open source of this function? or what is the best way to implement it?
thanks for your opinions
If you are planning to use Javascript on the client side, take a look at http://kiro.me/projects/fuse.html
However,70Mb of data is simply too much for any browser to handle and a client side search implementation is definitely not recommended.

Access remote MySQL database and update a table using javascript..?

I searched all over net for an hour i couldn't find a decent code for updating database using javascript. Can anyone just give me a reference please??
You can do that with Node.js
Here's a sample blog post from interwebz that shows how to do it:
http://www.giantflyingsaucer.com/blog/?p=2596
You need some kind of ServerSide Scripting (php, perl, cgi, java, etc.)
Take a look on this: JavaScript to update MySQL?
JavaScript on itself cannot query any DB for you, as it can work effectively only on the browser. To work with DB you can use use PHP , and use ajax to communicate using $.ajax or $.post methods. A simple search on this will get you references. In short you can use ajax to communicate with PHP script which will in turn query the DB for you.
To start you can take a look at this,
http://webcheatsheet.com/php/connect_mysql_database.php
Main thing to remember is Javascript will only affect your browser.
I hope this helps.
Regards

parsing jscript within sql server 2008

Is there a way to parse jscript which is stored in a server table. I am looking for something like eval(jscript function).
Well, using some hacks like this you can run managed code inside SQL server and upo that, use the JavaScriptSerializer class to deserialize the JSON objects. If you have JavaScript as a plain code, well, it would be funny If one was able to run that inside SQL :)

accessing a 'media:thumbnail' tag in rss feed using basic javascript xml

How would I access a mediarss tag like <media:thumbnail> using basic javascript like getElementsByTagName? P.S I do not want to use a library or server side scripting, also a json object is not available from the rss feed i am using, and i do not want to create one in php...
It seems this issue is covered here, where they talk about using getElementsByTagNameNS.

How to use qooxdoo with MySQL and PHP

I have a work assignment, and I don't have any alternative; I have to use the qooxdoo framework.
How can I do a query with MySQL and PHP using this framework? In the examples present in the site, all tables use random values or JSON values, but in this case, I need PHP.
I know that I can't use PHP code inside a JavaScript file, so is Ajax the unique solution?
How I can solve that?
You write a PHP RPC service which provides the data to your qooxdoo application. You can find more input on this in PHP RPC (qooxdoo documentation).
Another way is to create your own transport, for example, use AJAX to fetch JSONP.
See more info at http://manual.qooxdoo.org/1.3/pages/communication/remote_io.html

Categories