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
Related
I have a Oracle database server hosting data, and I want to build a small app on my local network for people to do light data entry.
Normally we can't query a database from the browser because the browser is client-side and the database is on the server.
But what if the server and website are both hosted on the local network? Would it then be possible? The problem is I don't have a server I'm just making a small website as a file on a shared drive.
But what if the server and website are both hosted on the local network?
This does not change almost anything, maybe it makes things a bit easier when it comes to application security.
Normally we can't query a database from the browser because the browser is client-side and the database is on the server.
That's not true. You can query a database from a browser/client-side. The problem behind such a solution is security of course, because in this case the client would have to know the database credentials, which is why such operations are performed on the server side, but it does not mean that querying database from client-side is not possible.
The conclusion is that if you know the database credentials anyway, it is possible to write a simple application (which will query database from client-side) for yourself. For this you can use OracleDB module.
---EDIT---
I will only emphasize once again that you should not make such an application available anywhere outside for security reasons (availability of database credentials).
However, you can use JavaScript fullstack frameworks like nextjs or sveltekit - they are able to perform some server-side operations and then pass this data to the client. This approach would be much safer.
I'd use Oracle Application Express.
It is installed in Oracle database; lets you develop applications rather quickly (if you know some SQL; even if you don't - use wizards). The only "tool" you need is a web browser. Your users would also need it (the browser), accessing your application via local network and enjoy beautiful application you'll create.
I understand this is not best practice but I am operating within a limited realm and, as far as I can tell, this is the only solution to this problem.
I am trying to connect to an MS-SQL database both to get data and to put data onto the database. I cannot seem to do it through JavaScript.
ActiveXObject is, from my understanding, now depreciated so that is not working, which eliminates every functional solution that I could find recommended in the past.
Please note: I am not a web developer and I have no access to any of the standard web development tools for this task.
This is the question has been asked multiple times in various forums - Can my client-side Javascript (running in a browser) connect to a database server and fetch data?
The short answer is - not recommended in general, not feasible without breaching security and without using outdated technologies. Let us dig into it.
It is possible to connect to remote database from a browser using outdated technologies
There are two pieces of technologies from Java and .Net worlds - Applet and ActiveX that run on the browser and can communicate to a remote database. The Java Applet is hardly used by anyone nowadays and browsers are stopping to support it. ActiveX is discontinued by Microsoft in their newer browser Edge. So, you have to enforce your target users to use old insecure browsers if you want to go with these options.
Do not use this.
Use databases embedded in the browser and sync with a remote database
You may use the database locally available in the browser and perform all read/write operations. Periodically sync this database with a remote one. Here are the options:
MongoDB and use change stream to sync with a remote MongoDB
PouchDB and sync with a remote CouchDB or even a MySQL database
Use this only for offline storage temporarily in the browser.
The traditional and secure approach to connect to a remote Database
Use a server-side technology to develop an app that your client-side code (Javascript, HTML) talks to. The app may provide RESTful APIs to interact from the client-side. Then the app that is running in a web server connects and interacts with the database. There are plenty of server-side technologies such as Java, PHP, Python, NodeJS (Javascript based), .Net, etc. to develop your server-side app.
Go with this option.
Well javascript is a client side scripting where as your database runs on a server. So firstly you cannot connect to a database for executing any query from client side i.e javascript and also you need to setup a server side service which can connect to the database and execute the query and give you the result at the client side. You can refer any client-server architecture for this on the web.
I would like to create a simple personal client based web app using Javascript which spits out Amazon product information based on ISBNs using the 'GetMatchingProductForId' operation - is this possible using a XMLHttpRequest Object or would I have to use one of the given libraries "PHP, C#, JAVA"?
I have experience in PHP and if I could not do the above I would use the PHP library but this would require it to be run on a server which I would rather not do.
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).
I'm working on a Parse web app and have run into some problems using the backbone.js based client side javascript sdk. I noticed the way I have things set up, the client can view all of my source code by simply using the dev tools to view source files and can also run code against the database (within the limits of the ACL's I've set). I've started working on rebuilding the app in cloud code using the Express.js module Parse provides so that all of my code is stored server side, but I was wondering how those using client side frameworks get around this obvious problem.
That's the issue with client-side code. Assume any code you send to the client is hacked, broken, and tampered with.
With JavaScript, your best bet is to use either Cloud Code and send AJAX or streaming data calls to the server, retrieve the data from the server at runtime (not super secure, but would fool some people), or accept that your code is vulnerable.
I typically work with frameworks in the MVC format, so I only expose a limited subset of the actual model via a REST API. I use both a client-side framework and a server-side framework. Any thing sensitive goes on the server.