parsing jscript within sql server 2008 - javascript

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 :)

Related

Proper way for Javascript to read MySQL data through Java

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.

Call Python script from local JavaScript App

so I've looked around quite a bit now and wasn't able to find quite the use case I think I am confronted with.
For some background:
I'm fairly new to JavaScript and have never had to call any other program/script from it. Now I did develop a Python script that pulls some data from online sources, formats it and dumps it into JSON files. In order to display this data in a proper way I figured I would use Electron.
While handling the JSON files is completely fine (would be quite sad if it wasn't I guess), I need to be able to call the Python script updating the data from my Electron UI. As everything is local, I hoped, that there would be an easier way, than setting up some server for the Python script to run on, just to be able to trigger its execution from my Desktop App. This is especially true, as I don't even need to get or process any returns, I just want to trigger the execution of that script.
So the question now is: is there such an "easy" way to execute Python scripts from an Electron/JavaScript based locally saved Desktop app?
Thanks in advance for any answers!
Like a previous commenter mentioned, you should be able to follow this SO answer in Node.js (which is what Electron uses).
To expound upon that answer just a bit, I'd recommend using the built-in Python JSON utility to dump JSON to the standard out (just printing out the JSON string), and the using the built-in Node.js JSON utility to parse that JSON string into a javascript object for use in your application.
Alright, so after being redirected to this thread, which I can only recommend reading through if you have an interest in this issue, I took their solution and altered a little, which took me a bit of time, due to some confusion, which I now would like to spare you guys!
To re-introduce the issue: The goal is to call a python script from a JavaScipt/Electron based UI. The python script only needs to be executed, but it needs to happen onClick, as it is an update function.
Now this is the code I used:
const exec = require("child_process").exec;
function triggerUpdateAndRefreshFooter() {
exec('python relativePathToScript/update.py',
function(error, stdout, stderr) { //callback function, receives script output
refreshFooter(); //don't use the output, but I could here
}
)
}
I did have some issues figuring out all of that const stuff in the other thread, as well as having to guess IF I could just execute my script in a separate function. In the end this did work!
I hope this was helpful!

Javascript in SoapUI

Javascript in SoapUI How to's?
In SoapUI, you are allowed to write Groovy Scripts !
but since even javascript is also supported in SoapUI
how can we write a javascript in SoapUI Is there a simple example which would explain this in much detail.Is there any simple code for automating the process of testing using javascript.
To switch a project to JavaScript, click on the project, travel to the window in the bottom left hand corner. Select the script language field and update it to JavaScript.
As far as what you can do with it, you can really do anything. You can create a script step or assertion. Some examples would include creating a script to create variables or looping through a response to verify information. I didn't find much on using JavaScript with soapUI either, and ended up sticking with Groovy. I found it to be powerful and extendable via Java if needed.
If you want a specific example on how to do something. I'd recommend asking a more specific question with what you have tried so far.
So far I've got...
function myFunction() {
log.info('Hello');
}
myFunction();
Output shows up in script log, when I work out how to loop tests etc, will post…
I've not tried JavaScript, but I have developed my own java classes which I use for complex response checks.
You don't have to change the scripting language in SoapUI. To call Java class, I have a groovy step in my test, which instantiates an object from my java class and I then invoke a key method on the object. You can pass in the objects that SoapUI passes into the groovy script so you can then process the response.
The java scripts themselves live in the bin/scripts folder under SoapUI.
When working on a java class, I use an external editor like Brackets. When I save the change, SoapUI detects that change and recompiles the java class, so yup don't need to restart SoapUI after every tweak to your class.
The smart bear site and other places have tutorials to get you up and running.

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

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