Socket client for aios server
The aios server is an in java implemeted lightweight server were currently different jdbc datasources can be registered and are accessible throw a socket connection. The exchanged messages an bson en-/decoded.
To use this package you need an aios server up and running.
Sources and documentation for the aios server can be found on https://github.com/thinkbaer/aios.
This is an experimantal implementation under active development don't use it on production systems!
Per default the aios server listens for socket connection on
- host: localhost
- port: 8118
Usage
Synchronized (with sockit-to-me)
Setup the server connection
var AiosServer = ; /** * Default implementation */var server = host:'localhost'port:8118; // Sends the current timestamp and receives server time and durationvar response = server;/*resonpse = { time: DateObject duration: long}*/
Register a JDBC datasource on aios server
// name for the datasource configurationvar dsn = 'hsql_test' // necassary specification for datasourcevar dsSpec = type: 'jdbc' driver: 'org.hsqldb.jdbc.JDBCDriver' // if the driverLocation is remote then the driver will be downloaded by the server // a local driver path will be directly used driverLocation: "http://central.maven.org/maven2/org/hsqldb/hsqldb/2.3.3/hsqldb-2.3.3.jar" url: "jdbc:hsqldb:file:/tmp/test_server/hsql_test" user: 'SA' password: '' // register the datasource on aios server (needed only once)var dataSource = server; // if the datasource is already registered, you can access the dataSource Object throughvar sameDataSource = server;
Query the registered datasource
var createDBSchema = 'CREATE TABLE IF NOT EXISTS car ( id INTEGER IDENTITY, type VARCHAR(256), name VARCHAR(256))' "INSERT INTO car (type, name) VALUES('Ford', 'Mustang')" "INSERT INTO car (type, name) VALUES('Volkswagen', 'Golf')" // like JDBC executeBatch // http://docs.oracle.com/javase/8/docs/api/java/sql/Statement.html#executeBatch--var results = ds; // like JDBC execute// http://docs.oracle.com/javase/8/docs/api/java/sql/Statement.html#execute--results = ds; // like JDBC executeUpdate// http://docs.oracle.com/javase/8/docs/api/java/sql/Statement.html#executeUpdate--results = ds; // like JDBC executeQuery// http://docs.oracle.com/javase/8/docs/api/java/sql/Statement.html#executeQuery--results = ds;// returns an array with query results
Asynchron (with net.Socket)
Currently not implemented, coming soon ...
// TODO
Links
aios server
nodejs aios client
Work in progress ...
- Error Handling
- Connection pooling
- Asynchon implementation
- Performance optimization
- Benchmarks