Can I connect to a database using JS?

Asked

Viewed 97 times

0

I am developing a website for myself and would like to know if I can use Javascript to connect to the database and get a value.

NOTE:The site is local, and the bank also and are on my machine, you know if I can connect using JS ? How?

  • I like to think that javascript could never connect to the database for security reasons, ever imagined that you can come on the site of Hotmail and hack the database through the browser? Well, it’s strange, but javascript runs in the browser and that’s why I believe it’s impossible for this language to provide (and why not the browser) accessibility to the site server (or database server).. I think something similar to database (although quite different), is localstorage(Html5) which offers the opportunity to record user information, but not permanently.

2 answers

1

Javascript should be used solely and exclusively for the client side, more precisely in the browser sandbox.

To communicate with the database inevitably you will need to work with some server side language. I personally point out PHP in these cases because it has almost zero dependency and most web servers have it by default.

0

In Mysql 5.7 you have the HTTP Plugin with which you can do what you want. There are other means as well, but this is the best known. The plugin is basically a REST API.

Another means is using Activexobject, connecting by ADODB ODBC. Of course, in this case the browser must have permissions to access the Activex object.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.