Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript and MySQL

I want to build an entire web app using only Javascript and MYSQL . How can I go about this if it's possible.

like image 899
Pita.O Avatar asked Feb 08 '09 09:02

Pita.O


4 Answers

Try something like Jaxer, which will allow you to execute JavaScript on the Web Server and query databases.

Here are some syntax examples and usages:


Database, file, and socket access from JavaScript

alt text http://jaxer.org/images/Picture+4_0.png


Easily create RESTful JSON data services

alt text http://jaxer.org/images/Picture+6.png


Directly call server-side functions from the browser

alt text http://jaxer.org/images/Picture+2_0.png


like image 131
Andreas Grech Avatar answered Oct 12 '22 16:10

Andreas Grech


You can do it with Jaxer. There are some screencasts that'll get you started. Also check out project Phobos. Jaxer integrates nicely in Aptana studio, Phobos in Netbeans.

like image 30
Vasil Avatar answered Oct 12 '22 17:10

Vasil


If you can run javascript on the server, you can build a web-application with it (without the need for any other language like PHP etc.). Search the web for 'connection string mysql' to find out how to connect to your mySQL database and use ADO/ODBC. You'll need the MySQL ODBC-connector on the MySQL server.

Here's an example database connection (where MySQL server resides on the same server as the web server):

function connectDB()
{
   var connectStr = "DRIVER={MySQL ODBC 3.51 Driver}; " +
                    "SERVER=localhost; "                +
                    "PORT=[MySQL server port];"         +
                    "DATABASE=[your database]; "        +
                    "UID=[username];PWD=[password];"    +
                    "OPTION=3",
       conection  = Server.CreateObject("ADODB.Connection"); 

  //ERRID=>lib::connectDB::open
   try       {connection.Open(connectStr)             }
   catch(e)  {errAlert(e,'rs::connectDB','connection failed',1) }        
   return connection;
}

(Where errAlert is a custom function to return the error)

like image 2
3 revs, 2 users 96% Avatar answered Oct 12 '22 15:10

3 revs, 2 users 96%


You could write your application entirely in client side javascript with AJAX / REST calls to your database server - using something like CloudKit on your server (or CouchDB, which features a native JSON HTTP interface). On the client side, Dojo or YUI abstract out a great deal of the IO handling…

like image 1
Naum Avatar answered Oct 12 '22 15:10

Naum