Questions | Login

Top / PHP / MySQL

how to establish connection from java script to mysql?

demo 17 Dec 2008 04:40am

Answers

demo 17 Dec 2008 04:45am
You would need a host environment that supported the database connection.

In ASP.NET, for example you would do something like http://msdn.microsoft.com/en-us/library/aa289163(VS.71).aspx but with MySQL as the database http://www.15seconds.com/issue/050407.htm
demo 17 Dec 2008 07:00am
If you really mean 'javascript,' You can't really connect javascript code directly to a database, because javascript usually (almost always) resides on the browser, and is forbidden from this kind of activity as a security precaution.

If you want to connect to mysql, you need some sort of programming language on the server end. Although there is a form of javascrpt that runs on the server, it's almost never used. Generally you'll use a language like PHP or ASP.NET.

If you really mean 'java' (a totally different language than javascript) you can use the JDBC connectivity tool in the SQL package.

You'll need a special driver for mySQL (freely available on the Internet)

First, you create a connection object, which represents the connection between your program and the database (think of it as a train track)

Then build a statement object from the connection. The statement is like a train. It's the object that will transport between the program and the database over the connection.

Use the statement's executeQuery() or executeUpdate() method to send SQL instructions to the database.

executeQuery will return a ResultSet object which you can parse to determine what happened.

Best of luck to you...

Related

Submit Answer

You must be logged in to post an answer. Please Login or Register.

Powered by phpMyAnswers.