aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Database access using Java Script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Database access using Java Script" Watch "Database access using Java Script" New topic
Author

Database access using Java Script

Nee Kat
Ranch Hand

Joined: Jan 27, 2004
Posts: 37
What is the best way to access/query data using javascript. I have to query an Oracle database.
Any sample code will be appreciated.

Regards,
Neekat
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
JavaScript can not access a database directly. IE can use ActiveX, but that is as close as you can get.

Eric
Nee Kat
Ranch Hand

Joined: Jan 27, 2004
Posts: 37
What about an XML document. Can I access data from an XML document using JS. The data is not that much so I can use an XML document. If yes, how to access using JS.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60041
    
  65

Using XMLHttpRequest (aka Ajax) you can access an XML document on the server. You cannot access anything on the client.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
The XML document also has to be on the same domain with Ajax.

Eric
Nee Kat
Ranch Hand

Joined: Jan 27, 2004
Posts: 37
I am confused.
If the document is stored on C:\home\code\menu.xml so can I access it using this code or not from a template which is stored on the same drive?

var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
xmldoc.async = false;
xmldoc.load("C:\home\code\menu.xml")



Regards,
Neekat
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39529
    
  27
When you mentioned JavaScript, the assumption was that the document would be served by a web server, in which case you can not access a document on a local machine using the "C:\..." notation. If you open the HTML file directly on your local machine, you can, but then there's not much point in making it a web page.


Ping & DNS - updated with new look and Ping home screen widget
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Here is a basic example:



Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Database access using Java Script
 
Similar Threads
Retreiving data
Inserting Data Into Ms Access Thru JDBC
how to enter date object in ms access database
Catching the content of drop down box
MySql and Tomcat connect with root, but not other user