开发者

Can we connect database with javascript

Is it possible to c开发者_开发知识库onnect database with javascript.


Yes, absolutely. Behold the DBSlayer: http://code.nytimes.com/projects/dbslayer/wiki

Developed by the New York Times to manage their high load, it is a HTTP/JSON to MySQL proxy. Just make an SQL request to it via HTTP and it will return a JSON object.

However, this is not really a good idea for both security reasons (people can simply delete whole tables and databases or get access to data you don't want them to see) and code readability reasons (your code will depend too much on database structure). But, if you're doing this on the server side via Node.js or Rhino for example then it's OK.


Not directly, but you can use WebServices to build your javascript-accesible business logic.
Here you can find an article how to handle webservices in javascript.

This solution is much safer then direct connection to database (for example your connection string is not exposed) and it can be use on static pages without any problems.


Please see if this is helpful to you :)

Personally I believe if you can include server-side javascript, then there must be a way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜