Connecting to a MySQL database using AngularJS - javascript

I'm trying to create a mobile application using AngularJS and Ionic Framework. However, I'm lost when trying to find a solution for backend database support. Is there a plugin or third-party API available to use to accomplish this?

Client side web applications do not connect directly to SQL database servers.
You need to pick a server side programming language and write a web service interface to your database.
Then access that interface using XMLHttpRequest (which Angular wraps with $http).

Related

Connecting WebSockets from browser to other applications

Presentation
My application is split in 3 parts :
C# .Net 5.0 desktop application that harvest and distribute data
Angular 10 static application that control the C# app (start/Stop) and
print the data in the form of charts for the user
Azure Function Rest API used as a backend for the Angular Static
Application (.NET core 3.1)
My goal is to have a WebSocket used for "real time" communication between the C# and Angular app instead of relying on Http Request to Azure Function REST api
I don't use a "classic" server like express.js. Azure Function replaces it fully.
Because of that, I'm using the service Azure WebPubSub to host the sockets.
Problem : I cannot connect the websocket I create from Angular (Browser Application).
The problem doesn't come from WebPubSub because the WebSockets are fully working (sending & receiving) between my C# app, Azure Functions and even some node.js test scripts.
Also, my web socket created in the browser app can communicate with itself but no other apps get the message send from my websocket in browser app.
Question : Can I communicate from the browser to others app in real time (websocket based) with my current architecture and if yes, how ?
On the Azure WebPubSub Documentation Page there are no examples of what I try to achieve. Same thing searching on the internet.
A solution using an Express.js server linked to the app, being the could be used as the middleman between the browser app and c# app. But I want to avoid it if possible.
I just want to know if what I'm trying to do is possible.
Also, the app could be re-done in React.js so non-Angular specific answer are better.
The Web PubSub logstream sample:https://learn.microsoft.com/azure/azure-web-pubsub/tutorial-subprotocol?tabs=javascript sounds like a similar scenario.
Your AngualrJS Web App is similar to the logstream's web application, and it joins the stream group.
Your C# .Net 5.0 desktop application is similar to the logstream's message publisher application stream: https://learn.microsoft.com/azure/azure-web-pubsub/tutorial-subprotocol?tabs=csharp#publish-messages-from-client, which send messages to the stream group.

Can I create web api using express.js and not have node.js installed?

I am currently in the process of creating a portfolio website for myself but due to hosting restrictions, I cannot make use of Node.js.
I know Angular can run on any web server, but is it possible to make use of Express.js to create web api's with relying on Node.js to run these web api's using Express.js?
If not, is there an alternative solution to create web api's that I can call using Angular and later for my mobile version of my website?
Please note that my shared hosting runs using cPanel.
As per definition Express.js, or simply Express, is a web application framework for Node.js so you can't do that. Alternatives would be to use a different backend language.
That also depends if your server supports them, for example, you can go with .NET CORE
You cannot use Express without NodeJS by definition so you have to deploy your backend somewhere else in you want to use it.
I suggest giving a look Firebase: you could write your backend using http cloud functions in express without paying anything until a reasonable amount of traffic (after that, is pretty cheap). You could also get rid of cPanel and deploy your frontend there via Firebase hosting.
Maybe you can try to build at first a web application with express. Of course you can create a web app without express if you need it. With express and Node.js I created a MySQL REST API. With HTML and Ajax you can fetch the Data from the API. So you can create two applications. One application where you need to run Node.js because it`s much easier to create a REST API with express. The second one is fully without Node.js.
Maybe there are better solutions, but inside each Web Application you can than but you can then access this API in any web application using jQuery. It doesn't matter if it is written with PHP, ASP.Net Core, Java EE / EE4J. You can also access this API in Ruby, Angular, React, Vue etc. using an AJAX request.
In some scenarios you can't start Node.js as a server because an application is already running on apache2 or nginx. There this would be a workaround to use something like this. For example, one could also integrate applications with HTML+JS in a CMS system that accesses other database tables and thus extend such a system without an iframe.
So can be helpful for few scenarios. Now just doesn't get around the actual goal of doing without Node.js completely or even express. But why are there REST APIs? So that you can query the data and incorporate it somewhere else. Otherwise you would have to build a REST API with another technology. Especially in the example of accessing MySQL with JavaScript, this would not be quickly feasible.
If you are looking for a similar solution to separate the web app and the REST API, but you don't need Node.js, then you should really build a REST API with .Net Core or with another technology, depending on what is possible and installed on your server. It could be Java or PHP behind it or Ruby.
The API that provides the REST access does not have to be written in JavaScript. You only need to be able to access it with JavaScript. So you can use many different approaches to access JSON data. I hope that in the short time with my bad English I have explained the basic idea, how to proceed stylistically and where advantages exist in REST interfaces.
With this, it should be self-explanatory that you don't have to use NodeJS and Express, but with JavaScript it's a pleasant solution. Only you have to ask yourself if a JavaScript application has to provide this interface at all or if in the end only a JavaScript application has to access this interface. Very big difference.
For backend rest api you can use golang with gorilla framework. Golang simple keyword and easy to learn.best important point is performance. If your server support golang you can use golang for backend..
ExpressJS is NodeJS framework so it's impossible to create an API without NodeJS.
Angular is front-end framework so you can host it on web hosting server.
If you need to create back-end APIs, you can use other clouding host servers that support NodeJS.
It's fairly simple to build this with just the net/http package. Set up a router that handles various commands and deal with the response accordingly.

Consuming OData from SAP System with JavaScript

I want to consume data in XML format from an SAP System.
To do that, I implemented an OData Service in the SAP System and activated it.
I tested it in my SAP Web IDE and it works.
But now I am developing another project in NetBeans consisting of HTML and JavaScript, and I want to consume the OData Service in that Project.
To reach that goal, I did a lot of research on the internet and read about a few options, but I'm still confused.
Is XMLHttpRequest the thing to achieve it, or is it Apache Olingo, etc.?
Can anybody please give me a clue which technology to use for it?
Apache Olingo is a framework used to expose an OData service in Java. You already have your OData service, you don't need to touch that.
Both the SAP Web IDE project and your HTML/JavaScript project in Netbeans are clients of your OData service, that is to say, they both query your OData service for data.
Both the SAP Web IDE project and your HTML/JavaScript project in Netbeans are frontend projects. They both use HTML/CSS/JS to display the page nicely and perform CRUD operations on the data.
XMLHttpRequest is an API which can be used in plain JavaScript to send requests. You're probably using it in your SAP Web IDE project to query your OData service. As such, you can use it also in your Netbeans project to query your OData service.
So query your OData service in your Netbeans project the same way you do in your Web IDE project.

Using a JS framework for developing a database client application?

Requirement:Using a JS frameworks and readily available UI elements to develop a database application (which would connect to databases the user wants to connect to using jdbc, and do some drag-and-drop SQL query building etc. and similar functionality)
I understand that I would need some parts of it needs to be residing in a web server. Since not all the users' databases (local, intranet) could be accessible from a central server where I run my application, I am thinking I would need to bundle the server also (apache tomcat) with my application. Is there any simpler tools/methods to architect this, keeping the UI in HTML5/JS?
Since you did not mention any limitations on the technology or framework to be used, see if you can use this.
MEAN -- MongoDB, Express, Angular and Node.
http://mean.io/#!/

Connect sqlite with HTML5 on server

How can I connect an HTML5 web application to a sqlite database which is on server side?
You need to use a server-side language such as php (or any other server-side language that has support for sqlite databases). A client-side application can't access anything on the server other than information exposed as http services (a web page or json web service for example). Your html5 application can use ajax to make the http request to the server-side script which actually makes the sqlite database queries and returns the information to your application. Using a good client-side library like jquery can make the ajax calls quite easy:
$.getJSON("path/to/server-side-script.php", function(dataReturned){
alert(dataReturned);
};
The code above is just an example - it may not be exactly correct, but you should get the idea. I won't put an example of what the server-side script would do to retrieve the data from sqlite and return it as JSON (or whatever data format you like) - they are easily found with a quick google/bing search.
Here are the blogs which explains connecting sqllite with html5
SQL Lite Class for HTML5 Database
Store Data in HTML5 Sql Lite

Categories

Resources