By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,731 Members | 1,129 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,731 IT Pros & Developers. It's quick & easy.

How to connect to oracle database from JavaScript?

P: 8
hi

i have databasse oracle i want to connected with javascript for handling query.
Expand|Select|Wrap|Line Numbers
  1. // information for my dababase 
  2.   Class.forName("oracle.jdbc.OracleDriver");
  3.   String url="jdbc:oracle:thin:@localhost:1521:orcl";
  4.       c=DriverManager.getConnection(url, "hr", "ntic");

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3.  var oracle = require('oracle');
  4. var connectData = {
  5.     hostname: "localhost",
  6.     port: 1521,
  7.     database: "orcl", // System ID (SID)
  8.     user: "hr",
  9.     password: "ntic"
  10.  
  11.     };
  12.     oracle.connect(connectData, function(err, connection) {
  13.  
  14.     if (err) { console.log("Error connecting to db:", err); return; }
  15.     connection.execute("SELECT systimestamp FROM dual", [], function(err, results) {
  16.         if (err) { console.log("Error executing query:", err); return; }
  17.  
  18.         console.log(results);
  19.         connection.close(); // call only when query is finished executing
  20.     });
  21. });
  22.         </script>
i do this but no worked

thansk
Apr 24 '15 #1
Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
what exactly does not work?
Apr 24 '15 #2

Post your reply

Sign in to post your reply or Sign up for a free account.