I want to create a chart where I can select a time period and query mongodb accordingly. I want to use Java to query MongoDb. I know how to connect MongoDb and Java but I'm not so clear about linking the java to my webpage(i.e. To pass the data from that java file to my webpage/javascript).
I know Ajax calls can be used to link to servlets, but I'm sort of lost. Please help.
You use the Java MongoDB driver to connect to and query MongoDB from within your Java application. https://docs.mongodb.org/getting-started/java/client/
You would make that data available to the browser (D3/JavaScript) the same way you would make any server-side data available to the browser. You could either add that data to the page as you are rendering the actual webpage, or you could return the data in response to an AJAX request.
Related
I'm creating an application that needs to pull certain data to show it to the user. This data is pulled via a JavaScript function that ideally I'd like to have on the server side, not on the source code of the page.
The flow should be:
User chooses 1 parameter in the website and clicks ok
Send a POST request to Django with that parameter
Django's view uses that parameter to pull another 4 parameters from the Django database
Somehow use this 4 parameters in the JavaScript function to get some timeseries data
Pass this data from JavaScript to the view, and from the view update the browser's template without the user refreshing the page
How can I pass the 4 parameters from Python to the JS function, and then the result of the JS function back to Python?
The reason I need to use JavaScript and not Python for retrieving that data is because JS has a specific library that would make my life so much easier.
I'm doing a project which I want to send sensor's data to Firebase database. This connection must be via GPRS. To set or to push any data to Firebase database, it should be done using javascript and HTML, but the Arduino can't use javascript directly. Is there any way to make the connection?
I have a website. Would it be helpful to do the connection?
I will be really thankful if someone gave me a simple steps to follow.
Thank you in advance.
You could request web site links ( http request) from the arduino.And in this request you can pass details to the database.This is how the data is stored to the database from Arduino.
I am bit back about firebase database.
But let me tell what we did for storing data to a normal database.We made a PHP script such that if its link is requested with data ,it would store the data to the database.Then we made Arduino code in such a way as to request that link each time with the corresponding value to be stored.So if you can do PHP scripting for firebase data entry then its easier ( just request that link from Arduino).I think PHP insertion to firebase database is available.
You can also pass data to a website too using the above method ( simple modification in url would do that ,pass data to be stored).But the problem is how you would store it to the database from that webpage.If you have a way for that you can try it too.
My Question is simple: which programming language do you recommand me to do what I want below.
I have an html page and some javascript. On the html page you see a card game and some actions of the card. In my javascript I hardcoded for the moment the cards of every players. In the future I don't want hardcoded decks. I want to get the info of which players has which cards in his hand from a mysql database.
I don't think javascript (or jquery) is the way to do it. What do you recommand me to use?
I think you need Ajax Calls, a MySQL database with phpmyAdmin for example and some php.
Ajax 101: https://gist.github.com/joelrojo/c54765a748cd87a395a2b865359d6add
You can consider nodejs. The package mysql can allow you to insert data into the database and read them when needed.
https://www.npmjs.com/package/mysql
Use PHP to retrieve info of which players has which cards in his hand from your MySQL database.
For further reference please refer http://php.net/docs.php
Since data set in SpagoBI could be created using scripts, I need to connect, query my MongoDB data base using javascript (or Groovy).
I need to use scripts to be able to execute aggregation on the mongoDB data, I can't use aggregation directly on my MongoDB because my data type is String
I dont know how to access my Database using scripts
Any ideas?
You should create a Mongo dataset. The steps to create are:
Step1: Create a Mongo datasource in the administrator console. Notes: the type must be JDBC and the value for Class input field must be "mongo"
JDBC: {unit_host}:{port}/${db}
CLASS: mongo
Step2: now you can create a dataset. The procedure is the same of the query datasets. The difference here is the language.. JS instead of SQL.
Take a look at the SpagoBI wiki in particolar here: http://wiki.spagobi.org/xwiki/bin/view/spagobi_server/data_set#HQueryDataSet28Mongo29
When connecting to mongoDB, you pass auth stuff in the url. Since the scripts lies on the client side, it would be hard to make the connection secure (unless you are talking about backend JavaScript). Anybody would be able to see how to connect to your DB and for instance delete all content.
I would suggest a simple api to interface the database. Then u control the access to what a user can do towards the database.
Or have I misunderstood the scenario?
I am trying to make an html app for local use, consisting of an HTML page using Google Maps API V3, a SQLite database, and a SimpleHTTPServer script.
The workflow is the following:
User starts the server and opens the page, which contains a map with a set of markers, and a form with filters similar to those of Google Fusion Tables;
User interacts with form, which sets some parameters for a query;
When the user clicks "Submit", page sends a request to HTTPServer, whose request handler queries the SQLite database and returns the result as JSON/JSONP/something-else;
Some function takes back the data and map is updated;
My doubts are more conceptual than anything else, and specifically I would like to know (how/where to look for):
How should I send a request for the server in javascript, and how to listen back to it?
How should the server send data to the request, in order to update its value instead of refreshing the page?
Sorry if my questions seem obvious, but HTTP is something very new to me, and so is client-server communication.
Thanks for reading!
I think you can use CGIHTTPServer.
ref:
http://pydoc.org/2.5.1/CGIHTTPServer.html
Q:How should I send a request for the server in javascript, and how to listen back to it
A:Please google "ajax". "jquery" is one of the most convenient javascript library for ajax.
Q:How should the server send data to the request
A:just use "print" in python script which is called by CGIHTTPServer.
In this case, the output of "print" will be the response to http client(web browser).
In the script mentioned above, you should extract request parameter sent by http client,
with "do_Get()" or do_Post() function.