Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Node.js und die Oracle-Datenbank

1,821 views

Published on

Dieser Vortrag stellt den neuen Node.js-Treiber "node-oracledb" vor und zeigt dessen Installation und erste Node.js Programme. Die Oracle-Datenbank wird mit Node.js-Paketen wie "express", "websocket" oder "mail-listener" kombiniert.

Published in: Software
  • Sie können Hilfe bekommen bei ⇒ www.WritersHilfe.com ⇐. Erfolg und Grüße!
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THE BOOK INTO AVAILABLE FORMAT (New Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THE can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THE is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBOOK .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, CookBOOK, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, EBOOK, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THE Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THE the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THE Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THE BOOK INTO AVAILABLE FORMAT (New Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THE can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THE is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBOOK .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, CookBOOK, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, EBOOK, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THE Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THE the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THE Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Node.js und die Oracle-Datenbank

  1. 1. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Oracle Developer Node.js und die Oracle-Datenbank Carsten Czarski Business Unit Database Oracle Deutschland B.V. & Co KG
  2. 2. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Inhalt • Node.js: Was ist das • Der Treiber für die Oracle-Datenbank: node-oracledb • Node.js und die Oracle-Datenbank am Beispiel – 1: Zugriff auf eine Tabelle und Ausgabe auf der Konsole – 2: Ausgabe von Tabellendaten als JSON über HTTP – 3: Mail-Listener: Automatisches Laden von Mails in Tabellen – 4: WebSockets meets Oracle Database
  3. 3. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Node.js Node.js is an open source, cross-platform runtime environment for server-side and networking applications. Node.js applications are written in JavaScript, and can be run within the Node.js runtime. Node.js provides an event-driven architecture and a non-blocking I/O API that optimizes an application's throughput and scalability. These technologies are commonly used for real-time web applications. Node.js uses the Google V8 JavaScript engine to execute code, and a large percentage of the basic modules are written in JavaScript. Node.js contains a built-in library to allow applications to act as a Web server without software such as Apache HTTP Server or IIS.
  4. 4. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Javascript auf dem Server
  5. 5. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Node.js ... • ... basiert auf der Google V8 Engine (JavaScript) – Open Source seit 2008 – Implementiert in C++ – Kompiliert Javascript mit einem Just In Time Compiler • ... ist asynchron und eventgetrieben – I/O-Gebundene API Calls sind nicht-blockierend – Entwickler übergibt eine Callback-Funktion – Interne Verwendung einer Event Queue
  6. 6. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Klassischer (synchroner) Programmablauf
  7. 7. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Asynchroner Programmablauf mit node.js
  8. 8. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Node Packaged Modules (npm)
  9. 9. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Populäre node.js Pakete • Express: HTTP Server • MailListener: Liest Mails aus einem IMAP/POP Postfach aus • Websockets: Server für HTML5 Websocket-Technologie • Webshot: HTML-Seiten abrufen und als Bild speichern • Node-Oracledb: Oracle-Datenbanktreiber für node.js
  10. 10. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. node-oracledb • node.js Treiber für die Oracle-Datenbank – "Offizieller" Treiber für die Oracle-Datenbank – Derzeit verfügbar: Version 0.2 (Early Adopter) – Produktionsversion wird 1.0 sein • Features – SQL and PL/SQL Execution, Binding using JavaScript objects or arrays, Query results as JavaScript objects or array, Conversion between JavaScript and Oracle types – Transaction Management, Connection Pooling, Statement Caching, Client Result Caching, End-to-end tracing – High Availability Features: Fast Application Notification (FAN), Runtime Load Balancing (RLB), Transparent Application Failover (TAF)
  11. 11. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Download von GitHub
  12. 12. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Voraussetzung: Python muss installiert sein • Version zwischen 2.5 und 3.0 $ python2.7 Python 2.7.9 (default, Jan 29 2015, 17:33:10) [GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>
  13. 13. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Installation node.js und node-oracledb ZIP-Archive auspacken Node.js testen Build node- oracledb Umgebung vorbereiten Erstes Programm
  14. 14. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Voraussetzungen – Linux-System • Download und Auspacken der ZIP-Archive • $ORACLE_HOMEOracle Instant Client (Basic + SDK) • $NODE_HOMENode.js • $NODE_ORACLEDB_HOMENode-oracledb $ ls instantclient_12_1 node-v0.10.36-linux-x64 node-oracledb-master $
  15. 15. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Installation node.js und node-oracledb ZIP-Archive auspacken Node.js testen Build node- oracledb Umgebung vorbereiten Erstes Programm
  16. 16. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Node.js installieren und einrichten • Starten von node.js mit "$NODE_HOME/bin/node" • Starten des Paketmanagers npm mit "$NODE_HOME/bin/node" $ cd $NODE_HOME $ ls bin ChangeLog include lib LICENSE node_modules README.md share $ ls ./bin node npm $ $NODE_HOME/bin/node -v v0.10.36 $ $NODE_HOME/bin/npm -v 1.4.28
  17. 17. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Proxy-Server und Umgebungsvariablen • Falls Node.js Umgebung hinter der Firewall • Package Manager braucht Internetverbindung $ export PATH=$NODE_HOME/bin:$PATH $ npm config set proxy=http://{proxy-server}:{port} $ npm config set https-proxy=http://{proxy-server}:{port}
  18. 18. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Installation node.js und node-oracledb ZIP-Archive auspacken Node.js testen Build node- oracledb Umgebung vorbereiten Erstes Programm
  19. 19. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Oracle Instant Client installieren • Verzeichnisstruktur nach Auspacken des ZIP-Archivs $ cd $ORACLE_HOME $ find . ./uidrvci ./libocci.so.12.1 ./libociei.so : ./xstreams.jar ./sdk ./sdk/include ./sdk/include/occiCommon.h ./sdk/include/occi.h ./sdk/include/occiData.h : Instantclient "BASIC" Instantclient "SDK"
  20. 20. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Umgebung für Build von "node-oracledb" vorbereiten • Symlink erzeugen • Umgebungsvariablen setzen $ ls $ORACLE_HOME/libcntsh.* libclntshcore.so.12.1 libclntsh.so.12.1 $ ln –s libclntsh.so.12.1 libclntsh.so $ ls libclntshcore.so.12.1 libclntsh.so libclntsh.so.12.1 $ export OCI_LIB_DIR = $ORACLE_HOME # Einmalig für Build $ export OCI_INC_DIR = $ORACLE_HOME/sdk/include # Einmalig für Build $ export LD_LIBRARY_PATH = $ORACLE_HOME:$LD_LIBRARY_PATH # Immer nötig
  21. 21. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Build von "node-oracledb" $ cd $NODE_ORACLEDB_HOME $ npm install > oracledb@0.2.4 install /home/oracle/node-oracledb-master > node-gyp rebuild make: Entering directory `/home/oracle/node-oracledb-master/build' CXX(target) Release/obj.target/oracledb/src/njs/src/njsOracle.o CXX(target) Release/obj.target/oracledb/src/njs/src/njsPool.o CXX(target) Release/obj.target/oracledb/src/njs/src/njsConnection.o CXX(target) Release/obj.target/oracledb/src/njs/src/njsMessages.o CXX(target) Release/obj.target/oracledb/src/dpi/src/dpiEnv.o CXX(target) Release/obj.target/oracledb/src/dpi/src/dpiEnvImpl.o CXX(target) Release/obj.target/oracledb/src/dpi/src/dpiException.o CXX(target) Release/obj.target/oracledb/src/dpi/src/dpiExceptionImpl.o CXX(target) Release/obj.target/oracledb/src/dpi/src/dpiConnImpl.o CXX(target) Release/obj.target/oracledb/src/dpi/src/dpiDateTimeArrayImpl.o CXX(target) Release/obj.target/oracledb/src/dpi/src/dpiPoolImpl.o CXX(target) Release/obj.target/oracledb/src/dpi/src/dpiStmtImpl.o CXX(target) Release/obj.target/oracledb/src/dpi/src/dpiUtils.o SOLINK_MODULE(target) Release/obj.target/oracledb.node SOLINK_MODULE(target) Release/obj.target/oracledb.node: Finished COPY Release/oracledb.node make: Leaving directory `/home/oracle/node-oracledb-master/build'
  22. 22. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Installation node.js und node-oracledb ZIP-Archive auspacken Node.js testen Build node- oracledb Umgebung vorbereiten Erstes Programm
  23. 23. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Arbeitsumgebung erzeugen • $ mkdir /home/oracle/nodework • $ cd /home/oracle/nodework • $ mkdir node_modules • $ cd node_modules
  24. 24. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. "node-oracledb" nach "node_modules" verschieben • $ mkdir /home/oracle/nodework • $ cd /home/oracle/nodework • $ mkdir node_modules • $ cd node_modules • $ mv $NODE_ORACLEDB_HOME .
  25. 25. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. "node-oracledb" nach "node_modules" verschieben • $ mkdir /home/oracle/nodework • $ cd /home/oracle/nodework • $ mkdir node_modules • $ cd node_modules • $ mv $NODE_ORACLEDB_HOME . • $ mv node-oracledb-master oracledb
  26. 26. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Installation node.js und node-oracledb ZIP-Archive auspacken Node.js testen Build node- oracledb Umgebung vorbereiten Erstes Programm
  27. 27. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Das erste "node-oracledb" Programm: emp.js var oracledb = require('oracledb'); oracledb.getConnection( { user : "scott", password : "tiger", connectString : "sccloud033:1521/orcl" }, function(err, connection) { if (err) {console.error(err.message); return;} connection.execute( "SELECT * from EMP where EMPNO=7839", [], function(err, result) { if (err) {console.log('%s', err.message); return;} console.log(result.rows); } ); }); console.log("Finished – really?");
  28. 28. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Verzeichnisstruktur
  29. 29. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Test: Das erste Node.js Programm $ node emp.js Finished. Really???? [ [ 7839, 'KING', 'PRESIDENT', null, Tue Nov 17 1981 00:00:00 GMT+0100 (CET), 5000, null, 10 ] ] $
  30. 30. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Zweites Programm: "JSON-HTTP-Server" var oracledb = require('oracledb'); var http = require('http'); oracledb.createPool( { user : "scott", password : "tiger", connectString : "sccloud033:1521/orcl", poolMin : 1, poolMax : 20 }, function(err, pool){ if (err) { ... } http.createServer(function (req, res) { pool.getConnection(function(err, connection){ if (err) { ... } connection.execute("select * from emp ", [], function(err, results) { if (err) { ... } connection.release(function (err) { if (err) { ... } }); res.writeHead(200, {'Content-Type': 'application/json'});! res.end(JSON.stringify(results.rows)); }) }) }).listen(1234, 'sccloud033.de.oracle.com') });
  31. 31. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Zweites Programm: "JSON-HTTP-Server" var oracledb = require('oracledb'); var http = require('http'); oracledb.createPool( { user : "scott", password : "tiger", connectString : "sccloud033:1521/orcl", poolMin : 1, poolMax : 20 }, function(err, pool){ if (err) { ... } http.createServer(function (req, res) { pool.getConnection(function(err, connection){ if (err) { ... } connection.execute("select * from emp ", [], function(err, results) { if (err) { ... } connection.release(function (err) { if (err) { ... } }); res.writeHead(200, {'Content-Type': 'application/json'});! res.end(JSON.stringify(results.rows)); }) }) }).listen(1234, 'sccloud033.de.oracle.com') });
  32. 32. Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
  33. 33. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Verzeichnisstruktur nach "npm install express"
  34. 34. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Express: Einfacher Webserver var express = require('express') function startServer () { var app = express(); app.get ("/emp/*", processEmp); app.get ("/dept/*", processDept); var server = app.listen(9000, function () { var host = server.address().address var port = server.address().port console.log('Table EMP REST Service listening at http://%s:%s', host, port); }); }
  35. 35. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Express: Einfacher Webserver function processEmp(req, res) { pool.getConnection(function(err, connection){ connection.execute( "select * from emp where (empno=:1 or :1 is null)", [req.params[0]], function(err, results) { connection.release(function (err) {}), res.writeHead(200, {'Content-Type': 'application/json'}); res.end(JSON.stringify(results.rows)); } ) }) }
  36. 36. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Ein wichtiger Tipp zwischendurch ...
  37. 37. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. IMAP Integration: Mail Listener
  38. 38. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Verzeichnisstruktur nach "npm install mail-listener2"
  39. 39. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. MailListener2: IMAP-Server mit Tabelle verbinden var mailListener = new MailListener({ username: "vorname.nachname@mycompany.com", password: "***********", host: "mailserver.mycompany.com", port: 993, tls: true, tlsOpTions: { rejectUnauthorized: false }, mailbox: "INBOX", searchFilter: ["UNSEEN"], markSeen: true, fetchUnreadOnStart: false, mailParserOptions: {streamAttachments: true}, attachments: false });
  40. 40. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. MailListener2: IMAP-Server mit Tabelle verbinden mailListener.on("mail", function(mail, seqno, attributes) { if (mail.subject.match(/^MAIL_NODETEST.*/)) { pool.getConnection(function(err, connection){ connection.execute( "insert into mails_nodejs (sender, subject, datetime) values (:1, :2, :3)", [mail.from[0].address, mail.subject, mail.date], function(err, results) { if (err) { console.log(err); } connection.commit(function (err) {…}); connection.release(function (err) {…}); console.log("storing message: "" + mail.subject + """); } ) }) } else { console.log("Ignoring Message: ""+mail.subject+"""); } });
  41. 41. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. HTML5-Websocket: Asynchrone Client-Benachrichtigung
  42. 42. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. HTML5 Websockets • Bidirektionale Verbindung zwischen Browser und Webserver – Browser sendet HTTP-Anfrage mit Upgrade Request für Websocket – Verbindung bleibt nach Server-Antwort offen – Server kann weitere Daten ohne erneute Client-Anfrage senden • Nutzen – Gut geeignet für jede Form der asynchronen Benachrichtigung – Ständiges Polling des Clients zum Server fällt weg
  43. 43. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. HTML5 Websockets im Internet Internet erfordert viele offene Websockets Leichtgewichtige Server-Technologie nötig Node.js
  44. 44. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. HTML5 Websockets mit Node.js DEMO Oracle Confidential – 4
  45. 45. Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
  46. 46. Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
  47. 47. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Weitere Informationen • Node.js Info und Download http://nodejs.org • Node Package Manager http://npmjs.org • Oracle-Treiber node-oracledb auf Github https://github.com/oracle/node-oracledb • Node.js Developer Center im OTN http://www.oracle.com/technetwork/database/database-technologies/node_js/oracle-node-js-2399407.html • Diskussionsforum node.js und Oracle https://community.oracle.com/community/database/developer-tools/node_js/content
  48. 48. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Carsten.Czarski@oracle.com http://tinyurl.com/apexcommunity http://sql-plsql-de.blogspot.com http://plsqlexecoscomm.sourceforge.net http://plsqlmailclient.sourceforge.net Twitter: @cczarski @oraclebudb Nächster Oracle Developer Monthly 20. Februar 2015 – 09:00 Uhr

×