Online Shopping : Computers : Programming : Languages : JavaScript : Database

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

184 of 274 people (67%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

JavaScript: How should i connect MySql database through JavaScript ?

Apr 2nd, 2009 07:29
engatoo engatoo, alex martin, Knud van Eeden, Colin Fraser, Jean-Bernard Valentaten, DILIP RAMAKRISHNAN,


Using only javascript, there is no way of doing so.
You will have to use a server-based script language (e.g. ASP, PHP, 
JSP ...).
HTH
----------------------------------------------------------------------
--- Knud van Eeden - 18 September 2001 - 02:35 -----------------------
Computer: Language: Interpreter: JavaScript: How should I connect mysql
database through JavaScript?
Method: ActiveX
Create e.g. an executable (which handles the database) and load it as
an ActiveX control in your client side webpage
Delphi: ActiveX Control: Create: Simple: How to create a Delphi 
executable and run it in IE browser?
http://www.faqts.com/knowledge_base/view.phtml/aid/25248/fid/175
---
---
Method: Supply filename to run as a URL
---
Possible *idea* for a solution:
(for example only if you insist to do it on the client side, e.g. your
own computer, you have no webserver running, and have only your
webbrowser to work with. So it can be seen as some possible
workaround. For example, most large IT organizations do not allow you 
to
run a (personal or local) web server, though you possibly might run a
(personal or local) database, so you are forced to look for some
workaround):
---
In general,
you can load and or run ANY executable file
(thus files with extension .exe, .com or .bat),
on the client side (or server side) in your browser,
via the JavaScript commands:
 document.location.href="yourexefile";
 or
 document.location.href="yourcomfile";
 or
 document.location.href="yourbatchfile";
(the only price you have to pay here, is always an extra
 confirmation click for that file, to 'Open' or 'Run this program from
 its current location', when asked for)
 for example:
  document.location.href="c:/program files/merlin/bin/mysql.exe";
---
(if you use pure HTML, use
  <A HREF="yourexefile"> run your exe file </a>
  or
  <A HREF="yourcomfile"> run your com file </a>
  or
  <A HREF="yourbatchfile"> run your batch file </a>
)
for example:
  <A HREF="c:\program files\merlin\bin\mysql.exe"> run your exe file
</a>
---
[Internet: see also:
http://www.faqts.com/knowledge_base/view.phtml/aid/5712/fid/53
and
http://www.faqts.com/knowledge_base/view.phtml/aid/1633]
---
---
You call then your MySql .exe, read the output with an external
program (e.g. written in VisualBasic, C++, Java, batch file, ...), and
generate dynamically an HTML file.
This HTML file output you read in your browser.
---
Possible idea of a scenario:
1. Make sure you have MySql installed
   (e.g. download the free MySql light database from
     http://www.abriasoft.com/products/product16.php
    (after registering first, by clicking on the
    left side on 'Click here to register')
   )
2. Create (by hand or dynamically) the SQL input for MySql
   for example:
   (Here we create the input by hand, so type the following text in
your favorite wordprocessor
   and save it e.g. as
    mysqlin.sql
   )
   USE mydatabaseexample;
   CREATE TABLE mytableexample ( userinfo VARCHAR( 79 ), productname
VARCHAR( 20 ), quantity VARCHAR( 5 ), creditcardnumber VARCHAR( 16 ),
creditcardnumberexpdate VARCHAR( 10 ), creditcardnumbername VARCHAR(
40 ), creditability VARCHAR( 20 ) );
   INSERT INTO mytableexample ( userinfo , productname , quantity ,
creditcardnumber , creditcardnumberexpdate , creditcardnumbername ,
creditability ) VALUES ( 'ElectionDatabase' , 'not found' , 'not
found' , 'not found' , 'not found' , 'not found' , 'not found' );
   SELECT * FROM mytableexample;
3. So create any batch file, containing the path to your MySql .exe 
file
   and create dynamically by printing e.g. an HTML, JS or XML file
   from your output.
   (You will have to do some extra programming to create your
   MySQL SQL input and create dynamically the MySQL output)
   for example:
   (Type the following text in your favorite wordprocessor,
   and save it e.g. as
    mysqlrun.bat
   )
    REM change here the path to your mysql .exe
    SET mysqlpathexe=c:\progra~1\merlin~1\mysql\bin
    REM change here the path to your mysql input
    SET mysqlpathinput=c:\bbc\taal
    REM change here the path to your mysql output
    SET mysqlpathoutput=c:\bbc\taal
    %mysqlpathexe%\mysqld.exe
    %mysqlpathexe%\mysqladmin.exe create mydatabaseexample
    %mysqlpathexe%\mysql.exe <%mysqlpathinput%\mysqlin.sql >%
mysqlpathinput%\mysqlout.htm
4. Create an HTML file, say c:\mysqloutput.htm,
   (in this simplest case it is not necessary to create this file,
    as redirection (using '>') of the MySql output text to a file is
used
    here with extension .htm, so you see thus just the output text
(without
    HTML markup tags like <HTML>, <BODY>, ...). More general, you
    will have to generate this by printing it, e.g. using print
    commands in that language like printf( "<HTML>",
    document.write( "<HTML>" ); echo <HTML>, or similar)
5. Create the JavaScript commands to run MySql .exe and capture
   the generated MySql output
   for example:
   (Type the following text in your favorite wordprocessor,
   and save it e.g. as
    mysqlrun.htm
   -- you will have to change the path, here is used c:/bbc/taal --
   )
 <HTML>
  <BODY>
   <BUTTON
     onClick='
document.location.href="file:///c:/bbc/taal/mysqlrun.bat";'
   >
    1. Run MySql batch file
   </button>
   <BUTTON
     onClick=' window.open( "file:///c:/bbc/taal/mysqlout.htm" );'
   >
    2. Get MySql output file
   </button>
  </body>
 </html>
6. Then start your browser, and load this file (say mysqlrun.htm)
   in your browser (e.g. by typing the URL of the path to this file,
   say c:\mysqlrun.htm, or by typing
    start mysqlrun.htm
   on the DOS command line)
   Then clicking first on the button 'Run MySql batch file' will call
your
   MySql .exe, input your SQL commands (e.g. via redirection '<'),
   and generate an SQL output file (e.g. via redirection '>').
   Then your external program should convert this output to HTML.
   Via after that pressing the button 'Get MySql output' you then read
   your MySql output text in your browser.
---
PS choose to 'Open'
   or
   'Run this program from its current location'
   that executable file when asked after clicking the appropriate 
button
---
PS Filenames in JavaScript:
   remember to use forward slash '/' in your filename(s),
   if appropriate, or that file or page might or will not be found
   thus for example use:
   c:/mysqlrun.bat
   and not
   c:\mysqlrun.bat
  or similarly use double backward slashes '\\' in your filename(s)
  (the first of the two backslashes is all the time used for escaping)
   thus for example use:
   c:\\mysql1.bat
   and not
   c:\mysqlrun.bat
  If you use filenames in pure HTML, you can just use the normal
  filename notation (like c:\mysqlrun.bat).
---
---
Method: MacroMedia ActionScript / Adobe JavaScript
The History of JavaScript and Databases
http://www.webreference.com/programming/javascript/j_s/column9/
---
---
Internet: see also:
---
JavaScript: Database: Overview: Can you give an overview of links?
http://www.faqts.com/knowledge_base/view.phtml/aid/31360
----------------------------------------------------------------------
Colin Fraser:
I doubt this is actually workable on a web server to provide a result 
to
a remote computer. This is long winded and convoluted code that I
suggest would collapse if a gentle breeze was blowing out of the
north-east. It is also the kind of code that i would rail against if 
one
of my team was to offer it up as a potential solution. It is far 
simpler
to use appropriate server-side scripting like PHP. 
I have found PHP to be relatively easy to learn, easy to use, with a
smaller overhead than ASP, or JSP, and considerably faster to run than
those, CFM and Java.
http://automobile.easyfindindia.com/
http://bollywood.easyfindindia.com/
http://cloth-shopping.onlineindiadiary.com/
http://easyfind.j4ulive.com/
http://www.onlineindiadiary.com/
http://finance-guide.easyfindindia.com/
http://freelance-jobs.onlineindiadiary.com/
http://gadgets.easyfindindia.com/
http://www.easyfindindia.com/
http://gift-ideas.easyfindindia.com/
http://health-fitness.easyfindindia.com/
http://home-improvement.j4ulive.com/
http://homedecor.easyfindindia.com/
http://mortgage.onlineindiadiary.com/
http://online-business.j4ulive.com/
http://online-education.j4ulive.com/
http://onlinein.j4ulive.com/
http://pets-online.easyfindindia.com/
http://realestate.easyfindindia.com/
http://sports-in-india.easyfindindia.com/
http://travel-guide.easyfindindia.com/
http://wedding-shopping.j4ulive.com/
http://www.j4ulive.com/
http://www.roo7e.com
http://www.roo7e.com
http://www.al33ab.com
http://ksacam.com
http://chat.ksacam.com
http://ksacam.info
http://oo2o.com
http://s4cam.com
http://saudi4cam.com				
http://voice.ksacam.com
http://سعودي-كام.oo2o.com
http://سعوديكام.com
http://xn--mgbply5cnrr.com
http://www.3rabstarz.com/vb
http://www.3rabstarz.com/vb
http://www.3rabstarz.com/
http://www.3rabstarz.com/vb
http://www.3rabstarz.com/
http://www.dir.3rabstarz.com/
http://www.up.3rabstarz.com
http://www.3rabstarz.com/vb/forumdisplay.php?f=5
http://www.3rabstarz.com/vb/forumdisplay.php?f=116
http://www.3rabstarz.com/vb/forumdisplay.php?f=66
http://www.3rabstarz.com/vb/forumdisplay.php?f=78
http://www.3rabstarz.com/vb/forumdisplay.php?f=147
http://www.3rabstarz.com/vb/forumdisplay.php?f=2
http://www.3rabstarz.com/vb/forumdisplay.php?f=31
http://www.3rabstarz.com/vb/forumdisplay.php?f=136
http://www.3rabstarz.com/vb/forumdisplay.php?f=34
http://www.3rabstarz.com/vb/forumdisplay.php?f=89
http://www.3rabstarz.com/vb/forumdisplay.php?f=26
http://www.3rabstarz.com/vb/forumdisplay.php?f=72
http://www.3rabstarz.com/vb/forumdisplay.php?f=73
http://www.3rabstarz.com/vb/forumdisplay.php?f=149
http://www.3rabstarz.com/vb/forumdisplay.php?f=150
http://www.3rabstarz.com/vb/forumdisplay.php?f=151
http://www.3rabstarz.com/vb/forumdisplay.php?f=152
http://www.3rabstarz.com/vb/forumdisplay.php?f=67
http://www.3rabstarz.com/vb/forumdisplay.php?f=3
http://www.3rabstarz.com/vb/forumdisplay.php?f=37
http://www.3rabstarz.com/vb/forumdisplay.php?f=115
http://www.3rabstarz.com/vb/forumdisplay.php?f=76
http://www.3rabstarz.com/vb/forumdisplay.php?f=77
http://www.3rabstarz.com/vb/forumdisplay.php?f=36
http://www.3rabstarz.com/vb/forumdisplay.php?f=153
http://www.3rabstarz.com/vb/forumdisplay.php?f=122
http://www.3rabstarz.com/vb/forumdisplay.php?f=118
http://www.3rabstarz.com/vb/forumdisplay.php?f=119
http://www.3rabstarz.com/vb/forumdisplay.php?f=120
http://www.3rabstarz.com/vb/forumdisplay.php?f=121
http://www.3rabstarz.com/vb/forumdisplay.php?f=35
http://www.3rabstarz.com/vb/forumdisplay.php?f=65
http://www.3rabstarz.com/vb/forumdisplay.php?f=7
http://www.3rabstarz.com/vb/forumdisplay.php?f=9
http://www.3rabstarz.com/vb/forumdisplay.php?f=11
http://www.3rabstarz.com/vb/forumdisplay.php?f=142
http://www.3rabstarz.com/vb/forumdisplay.php?f=143
http://www.3rabstarz.com/vb/forumdisplay.php?f=146
http://www.3rabstarz.com/vb/forumdisplay.php?f=140
http://www.3rabstarz.com/vb/forumdisplay.php?f=137
http://www.3rabstarz.com/vb/forumdisplay.php?f=114
http://www.3rabstarz.com/vb/forumdisplay.php?f=117
http://www.3rabstarz.com/vb/forumdisplay.php?f=113
http://www.3rabstarz.com/vb/forumdisplay.php?f=51
http://www.3rabstarz.com/vb/forumdisplay.php?f=84
http://www.3rabstarz.com/vb/forumdisplay.php?f=138
http://www.3rabstarz.com/vb/forumdisplay.php?f=139
http://www.3rabstarz.com/vb/forumdisplay.php?f=15
http://www.3rabstarz.com/vb/forumdisplay.php?f=130
http://www.3rabstarz.com/vb/forumdisplay.php?f=97
http://www.3rabstarz.com/vb/forumdisplay.php?f=102
http://www.3rabstarz.com/vb/forumdisplay.php?f=101
http://www.3rabstarz.com/vb/forumdisplay.php?f=104
http://www.3rabstarz.com/vb/forumdisplay.php?f=131
http://www.3rabstarz.com/vb/forumdisplay.php?f=103
http://www.3rabstarz.com/vb/forumdisplay.php?f=99
http://www.3rabstarz.com/vb/forumdisplay.php?f=59
http://www.3rabstarz.com/vb/forumdisplay.php?f=60
http://www.3rabstarz.com/vb/forumdisplay.php?f=39
http://www.3rabstarz.com/vb/forumdisplay.php?f=40
http://www.3rabstarz.com/vb/forumdisplay.php?f=42
http://www.3rabstarz.com/vb/forumdisplay.php?f=4
http://www.3rabstarz.com/vb/forumdisplay.php?f=1
http://www.3rabstarz.com/vb/forumdisplay.php?f=88
http://www.3rabstarz.com/vb/forumdisplay.php?f=148
http://www.3rabstarz.com/vb/forumdisplay.php?f=62
http://www.3rabstarz.com/vb/forumdisplay.php?f=63
http://www.3rabstarz.com/vb/forumdisplay.php?f=64
http://www.3rabstarz.com/vb/forumdisplay.php?f=6
http://www.3rabstarz.com/vb/forumdisplay.php?f=12
http://www.3rabstarz.com/vb/forumdisplay.php?f=96
http://www.3rabstarz.com/vb/forumdisplay.php?f=58
http://www.3rabstarz.com/vb/forumdisplay.php?f=38