Skip to content

Commit

Permalink
Milestone 1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
www.cubrid.org committed Aug 18, 2012
0 parents commit 22ea140
Show file tree
Hide file tree
Showing 61 changed files with 4,667 additions and 0 deletions.
1 change: 1 addition & 0 deletions CUBRID version supported.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
>=8.4.1.2030
50 changes: 50 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Copyright (c) 2008-2012, Search Solution Corporation.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the Search Solution Corporation nor the names of its contributors may be used to endorse
or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


Project notes
==================================================================================================================================
Part of this software uses code from the node-mysql project:
https://github.com/felixge/node-mysql
See below the license of the node-mysql project.


Additional licenses
==================================================================================================================================
Copyright (c) 2012 Felix Geisendörfer (felix@debuggable.com) and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

82 changes: 82 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
node-cubrid
June-August, 2012
http://www.cubrid.org


Introduction
=======================================================================================================
The CUBRID node.js driver is an open-source project with the goal of implementing a 100% native node.js driver for the CUBRID database engine (www.cubrid.org).

The driver is currently under development and this (August 2012) is the first release (Milestone 1) of the driver code, which features:
- 2.000+ LOC
- Connect/Close, Query, Execute, Fetch, Close request etc. completed
- 15+ functional test cases
- 15+ unit tests
- E2E demos

These are the main project deliverables we target for the project:
- The driver source code
- Test cases
- Code documentation
- Demos & Tutorials
- npm package; registered on http://search.npmjs.org/


Installation
=======================================================================================================

This first release does not feature yet an npm installer – it will be available in the upcoming beta release.
Therefore, if you want to use it now, please download the driver code on your machine.


Usage
=======================================================================================================
This first release contains many test cases and demos which will show you how to use the driver.
These examples are located in the following (sub)folders:
\demo
\src\test


TODOs
=======================================================================================================
In the next code release (Technology preview - September 2012), we are targeting:
- Transactions support
- Additional data types support
- Schema support
- Documentation release
- More functionality & more testing
- Additional demos and E2E scenarios
- Code improvements, optimizations and refactoring


Author and Contributors
=======================================================================================================
The main authors of this driver are the members of the CUBRID API team - http://www.cubrid.org/wiki_apis.

We welcome any contributors and we hope you will enjoy coding with CUBRID! J


Special thanks
=======================================================================================================
We would like to thanks to the following people & projects for inspiration,
code we have reused and for doing such a great job for the open-source community!
- https://github.com/caolan/async
- https://github.com/felixge/node-mysql
- https://github.com/jeromeetienne/microcache.js


TODO
=======================================================================================================
This release is just the first milestone for this project.
We intend to release soon a beta version, followed by a stable release, with demos and tutorials.
Here are the scheduled releases:
- Milestone 1. Basic driver interfaces: connect, queries support
- Milestone 2. Technology preview release: ~80% functionality ready
- Milestone 3. Beta release
- Milestone 4. Stable release
- Milestone 5. Tutorials & Installer/Package completed; web awareness achieved.

...Stay tuned! :)



74 changes: 74 additions & 0 deletions demo/DemoServer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
var http = require('http'),
Result2Array = require('../src/resultset/Result2Array'),
client = require('../index.js').createDefaultCUBRIDDemodbConnection();

//Note: Open http://localhost:8080 to test it

function resultToHtmlTable(result) {
var ret = '';

ret += ' <h1>Table `code` content</h1>';
ret += ' <table border=1>';

var arr = Result2Array.GetResultsArray(result);
for (var i = 0; i < arr.length; i++) {
ret += ' <tr>';
for (var j = 0; j < arr[i].length; j++) {
ret += ' <td>';
ret += ' ' + arr[i][j];
ret += ' </td>';
}
ret += ' </tr>';
}
ret += ' </table>';

return ret;
}

http.createServer(function (request, response) {
if (request.url == '/') {
client.connect(function (err) {
if (err) {
response.end(err.message);
} else {
client.query('select * from code', function (err, result, queryHandle) {
if (err) {
response.end(err.message);
} else {
var output = '';
output += '<html>';
output += ' <head>';
output += ' <title>CUBRID Node.js Driver test</title>';
output += ' <style type="text/css">';
output += ' html, body {';
output += ' font: normal 0.9em arial, helvetica;';
output += ' }';
output += ' </style>';
output += ' </head>';
output += ' <body>';
output += resultToHtmlTable(result);
output += ' </body>';
output += '</html>';
client.closeRequest(queryHandle, function (err) {
if (err) {
response.end(err.message);
} else {
client.close(function (err) {
if (err) {
response.end(err.message);
}
});
response.writeHead(200, {'Content-Type' : 'text/html'});
response.end(output);
}
})
}
})
}
})
} else {
response.writeHead(404, {'Content-Type' : 'text/plain'});
response.end('Error: Unexpected request!');
}
}).listen(8080, 'localhost');

66 changes: 66 additions & 0 deletions demo/E2E_01.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
var client = require('../index.js').createDefaultCUBRIDDemodbConnection(),
Result2Array = require('../src/resultset/Result2Array');

var sql = 'select * from game';

client.connect(function (err) {
if (err) {
throw err.message;
} else {
console.log('Connected successfully to ' + client.brokerServer + ':' + client.connectionBrokerPort + '.');
client.getEngineVersion(function (err, result) {
if (err) {
throw err.message;
} else {
console.log('CUBRID Engine version is: ' + result);
console.log('Querying: [' + sql + ']');
client.query(sql, function (err, queryResults, queryHandle) {
if (err) {
throw err.message;
} else {
console.log('Query results - Rows count: ' + Result2Array.GetResultsCount(queryResults));
console.log('Query results - Column names: ' + Result2Array.GetResultsColumnNamesArray(queryResults));
console.log('Query results - Column data types: ' + Result2Array.GetResultsColumnsTypeArray(queryResults));
console.log('Query results - Data [displaying only the first 10 rows]:');
var arr = Result2Array.GetResultsArray(queryResults);
for (var j = 0; j < 10; j++) {
console.log(arr[j].toString());
}
console.log('Fetching more results:');
client.fetch(queryHandle, function (err, result) {
if (err) {
throw err.message;
} else {
if (result) {
console.log('Fetch results - Data [displaying only the first 10 rows]:');
var arr = Result2Array.GetResultsArray(result);
for (var k = 0; k < 10; k++) {
console.log(arr[k].toString());
}
} else {
console.log('There is no more data to fetch.');
}
client.closeRequest(queryHandle, function (err) {
if (err) {
throw err.message;
} else {
console.log('Query closed.');
client.close(function (err) {
if (err) {
throw err.message;
} else {
console.log('Connection closed.');
}
})
}
})
}
})
}
})
}
})
}
});


59 changes: 59 additions & 0 deletions demo/E2E_02.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
var client = require('../index.js').createDefaultCUBRIDDemodbConnection(),
Result2Array = require('../src/resultset/Result2Array');

var sqlsSetup = ['drop table if exists node_test',
'create table node_test(id int)',
'insert into node_test values(1), (22)'];
var sqlQuery = 'select * from node_test';
var sqlsCleanup = 'drop table node_test';

client.connect(function (err) {
if (err) {
throw err.message;
} else {
console.log('Connected to ' + client.brokerServer + ':' + client.connectionBrokerPort + '.');
console.log('Creating test data...');
client.batchExecuteNoQuery(sqlsSetup, function (err) {
if (err) {
throw err.message;
} else {
console.log('Querying: [' + sqlQuery + ']');
client.query(sqlQuery, function (err, queryResults, queryHandle) {
if (err) {
throw err.message;
} else {
console.log('Query results - Rows count: ' + Result2Array.GetResultsCount(queryResults));
console.log('Query results - Column names: ' + Result2Array.GetResultsColumnNamesArray(queryResults));
console.log('Query results - Column data types: ' + Result2Array.GetResultsColumnsTypeArray(queryResults));
console.log('Query results:');
var arr = Result2Array.GetResultsArray(queryResults);
for (var j = 0; j < arr.length; j++) {
console.log(arr[j].toString());
}
client.closeRequest(queryHandle, function (err) {
if (err) {
throw err.message;
} else {
client.batchExecuteNoQuery(sqlsCleanup, function (err) {
if (err) {
throw err.message;
} else {
console.log('Cleanup done.');
client.close(function (err) {
if (err) {
throw err.message;
} else {
console.log('Connection closed.');
}
})
}
})
}
})
}
})
}
})
}
});

24 changes: 24 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var CUBRIDConnection = require('./src/CUBRIDConnection');

/**
* Creates a new CUBRID connection
* @param brokerServer
* @param brokerPort
* @param user
* @param password
* @param database
* @return {*}
*/
exports.createCUBRIDConnection = function(brokerServer, brokerPort, user, password, database) {
return new CUBRIDConnection(brokerServer, brokerPort, user, password, database);
};

/**
* Creates a new CUBRID connection to the demodb database, with the default parameters
* @return {*}
*/
exports.createDefaultCUBRIDDemodbConnection = function() {
//return new CUBRIDConnection('localhost', 33000, 'public', '', 'demodb');
return this.createCUBRIDConnection('localhost', 33000, 'public', '', 'demodb');
};

Binary file added installer/CUBRID.ico
Binary file not shown.
Loading

0 comments on commit 22ea140

Please sign in to comment.