Skip to Main Content

Programming Languages & Frameworks

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Relational to JSON with Node.js

danmcghan-OracleJul 15 2015 — edited Jul 15 2015

Hi Everyone,

I just finished a blog post on converting relational data to JSON with Node.js: https://jsao.io/2015/07/relational-to-json-with-ords/

The post touches on several ways to optimize code that uses the Node.js driver, from using connection pools to executing code in parallel where appropriate. 

This is the last in a 4 part series that covers various ways of doing such conversions.

Regards,

Dan

Comments

BarryB

I didn't figure it out, (didn't get any help on SO either).
So I made a workaround by saving it to a table.

It probably looks horrible to a Java programmer but seems to work.

//Save the message to 
           ByteArrayOutputStream bos = new ByteArrayOutputStream();
           ByteArrayInputStream bis = null;
           //memory = new MemoryStream ();
           try  {
                msg.writeTo(bos);
                int i = bos.toByteArray().length;
                byte[] array = new byte[i];
                array = bos.toByteArray();
                
                
                
                //insertIntoProducts(desBlob);
                Connection conn = DriverManager.getConnection("jdbc:default:connection:");
                Blob desBlob = conn.createBlob();
                desBlob.setBytes(1, array);
                //PreparedStatement ps2 = conn.prepareStatement("insert into mytable values (hextoraw(?))");
                PreparedStatement ps2 = conn.prepareStatement("insert into barry_testtable(blobcolumn) values (?)");
                ps2.setBytes(1,array);
                try{
                int rowsAffected = ps2.executeUpdate();
                System.out.println(rowsAffected); //1
                } catch (SQLException e) {
                    System.err.format("SQL State: %s\n%s", e.getSQLState(), e.getMessage());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                
           }catch(Exception exp){
               exp.printStackTrace();}
1 - 1

Post Details

Added on Jul 15 2015
0 comments
589 views