Pages

Wednesday, June 04, 2014

Node Road show recap. When to use and not use node.


I was recently at a Node road show.  This was very much like the OTN tour just obvious focused on Node.  They had multiple big customers there to share how they used node, what worked, and what doesn't.  There were 3 things that stood out for for me about when when to use Node.

First, that node is designed for high concurrency low latency.  In case you didn't know node has 1 execution thread.  Here's a blog that explains it very well, http://www.aaronstannard.com/post/2011/12/14/Intro-to-NodeJS-for-NET-Developers.aspx.  That means a simple loop like while(true){} will lock up the entire node server.  Now, you may think oracle's OCI is not async so it's all lost.  Node takes care of when it's waiting on I/O.  While waiting on I/O from the database, node.js will push this work to the queue until there's a response then it comes back to the main thread for more execution.

Second, Node as the Front End's Backend.  Yahoo and Rakuten was there and explained how they use node to be the buffer from the front end to the "real" backend.  This makes a place where the front end developers can use what they know , javascript, and perform server side operations.  They can use the same REST based access the browser would use to also access the backend.

Third, A lot of people probably know this but is not meant for thing like finance.  Here's a simple example that math isn't a main point when it matters.  There are plans for Javascript to add a bigdecimal eventually which would remedy this.





Tuesday, June 03, 2014

Publish data over REST with Node.js

Of course the best way to expose database data over REST is with Oracle REST Data Services.  If you haven't read over the Statement of Direction, it's worth the couple minutes it takes.  The auto table enablement and filtering is quite nice.

For anyone interested in node.js and oracle, this is a very quick example of publishing the emp table over REST for use by anyone that would prefer REST over sql*net.  For example from javascript,php,perl,...



The current best driver for node.js to access oracle is node-oracle which is found here: https://github.com/joeferner/node-oracle


Here's a short set of steps to get going.

1. Install node, http://nodejs.org/download/

2. Setup the environment's oracle variables

export PATH=$PATH:.  
export ORACLE_HOME=/path/to/my/oracle/product/11.2.0/dbhome_1
export OCI_LIB_DIR=$ORACLE_HOME/lib
export OCI_INCLUDE_DIR=$ORACLE_HOME/rdbms/public
export OCI_VERSION=11 #Integer. Optional, defaults to '11'
export NLS_LANG=.UTF8 # Optional, but required to support international characters
export LD_LIBRARY_PATH=$ORACLE_HOME/lib

3. run npm install oracle

That's all there is to getting then env setup for oracle.  The other node package I use in this example is express.

4. To install that just type:  npm install express To learn more about express, it's home is here http://expressjs.com/



var express = require('express');
var app = express();
// This make a uri end point for the REST call
// http://myhost/emp will return the data
app.get('/emp', function(req, res){
  empList(req,res)
  }
);

var oracle = require('oracle');
var conn;

var connectData = {
    hostname: "127.0.0.1",
    port: 1521,
    database: "XE", 
    user: "klrice",
    password: "fortim"
}

// connect
//var conn="";
oracle.connect(connectData, function(err, connection) {
    if (err) { console.log("Error connecting to db:", err); return; }
    console.log('connected');
    conn =connection;
});

// function registered in the /emp declaration
function empList(req,res){
     var empList = "select * from emp ";
    conn.execute(empList, [], function(err, results) {
            if (err) { console.log("Error executing query:", err); return; }

            // use the JSON function to format the results and print
            res.write(JSON.stringify(results));
            res.end();
    });
}

// listen on port 8000
app.listen(8000);



The result is that the node script is listening on port 8000 for /emp and will return this JSON.









Monday, April 28, 2014

KScope14's Sunday Database Symposium

    This is the 3rd year Chet aka oraclenerd  and I have organized the Sunday Symposium.  This year has a bunch of great speakers with great content.  So, if you are debating at all getting to KScope a day early to make the symposium, here's the agenda for the DB Symposium and debate no more get there early !



Starting off the APEX and DB tracks will be combined.  


Oracle Database Tools  -  Mike Hichwa 


Mike Hichwa, Vice President of Database Tools, will provide an insight into the latest development of database tools and the Oracle Database Cloud Service. Everybody who is currently utilizing Oracle database tools should attend this session. 

Restful Access to Your Data  -  Kris Rice 


Representational State Transfer (REST) enables data to be shared over HTTP(s) allowing data access from virtually any platform or language. Oracle REST Data Services ( ORDS ) make this easier than ever to RESTfully enable your database. This session will start with an overview of what REST is and why it is growing in popularity as well as cover all the upcoming features in ORDS that includes: Auto enablement of relational data, Oracle Database 12 JSON support, and Oracle NoSQL support.  

Split to separate DB track


Best PL/SQL Features You Never Heard Of (or certainly don’t use)  - Steven Feuerstein


Hop out of the deep ruts of your programming habit and learn how to take advantage of some under-utilized but very powerful features of the finest database programming language in Planet Earth.

Storing and Querying JSON Data in Oracle Database 12c  -  Mark Drake 


JSON has been widely adopted as a mechanism for persisting structured and semi-structured data in recent years. Application developers are particularly attracted to the schema later / schema never nature of JSON, which allows them to evolve their application data model at will. The rising popularity of JSON has been accompanied by wider adoption of 'document stores' such as MongoDB and CouchDB.
    This session will show how new features of Oracle Database 12c allow the database to be used as a JSON document store. It will show how the database can deliver JSON storage, indexing and queryability, combined with performance, and full life-cycle support for JSON data, while still providing developers with all the flexibility that attracted them to JSON in the first place. The session will also touch on new API’s that make it very easy to use the Oracle Database as a JSON Document store. These new APIs are designed to support the programming paradigms and frameworks used by today’s cutting-edge developer They enable the use of popular document centric approaches, such as REST,  to be used to perform Create, Retrieve, Update and Delete operations on JSON documents managed by an Oracle database, without having to make use of traditional relational technology such as SQL, OCI, or JDBC.

Oracle SQL Developer and Oracle Database 12c  - Jeff Smith


Discover and exploit new Oracle Database 12c features such as multitenant container databases and data redaction with Oracle SQL Developer. This session also covers other Oracle Database 12c SQL and PL/SQL language enhancements that are available to all Oracle SQL Developer users. 

Applications HA Solutions for Planned and Unplanned Database Outages - Kuassi Mensah 



Upon database instance outage, applications are confronted with four issues: (1) hang and control loss, (2) error handling, (3) reliable determination of the outcome of in-flight work, and (4) resubmission of uncommitted transactions. This session introduces Oracle Database 12cApplication Continuity, which addresses all four issues. Fast Application Notification addresses the hang, Recoverable Error classification enables applications to interpret SQL exceptions without maintaining a list of error codes, Transaction Guard enables reliable determination of the outcome of in-flight work, and Application Continuity solves the resubmission of the uncommitted transaction. The session also discusses configuration and design considerations.

Tuesday, February 25, 2014

Hat Trick Tuesday - 3 new releases

  There's 3 new releases today from the database tools teams.  For non-hockey folks, a hat trick is when you get 3 goals in 1 game.  In our world of software, 3 releases at once is the closest thing ( I think ).



First up is SQL Developer, with over 3.5m users now it is by far the database IDE for Oracle databases.

SQL Developer 4.0.1


  The Oracle IDE for the database has come a long ways from when we started.  Everyone should upgrade to this latest patch as there are lots of fixes in there, the full list is here.  The tool continues to grow from where we started with over 3.5m users now.  Looking over the documentation from previous release really shows how much it has grown.

SQL Developer 1.1 Worksheet


SQL Developer Datamodeler 4.0.1

   The same applies to the modeler, there are a bunch of fixes in here.  However, there are also a bunch of new features included in this patch. Such as the mouse wheel now works to zoom in/ out and a dialog to make it easier to add/remove objects from subviews.  The other great thing about the modeler is it's already inside SQL Developer.




Oracle REST Data Services 2.0.6 ( formerly Oracle APEX Listener )


    The biggest change is the Oracle Apex Listener is now named Oracle REST Data Services.  

   What does this name change mean to you?

  • Forum Name changed
  • OTN URLs, Links changed
  • The file name changed apex.war is now ords.war
  • Default URL is now /ords

   The biggest reason for this change is to put an emphasis on where the majority of development work is going.  There's a lot of new features coming for REST to easier enable your relational, non-relational, and nosql data in the next release.

   The new name has no impact on the support of Application Express.  The support for OWA toolkit which Application Express relies on will continue to be enhanced.

   We will be building a Statement of Direction soon to let everyone know where this is headed.  In the mean time, there's a lot of example on this blog and on Colm's blog