Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rhildred/derbytest

derby openshift maven starting point
https://github.com/rhildred/derbytest

Last synced: 14 days ago
JSON representation

derby openshift maven starting point

Awesome Lists containing this project

README

        

derbytest
=========

derbytest is an embedded derby database that can be hosted on openshift

features include:

- connects in the data directory so that database maintains state across commits
- migration script (using flyway) is raked on every push to openshift

An example is ca.on.conestogac.Lab4.

package ca.on.conestogac;

import java.sql.*;

public class Lab4 {
public static void main(String[] args) {
//set these to be null so that we can finally close them
Connection connection = null;
Statement oStmt = null;
try{
//make a stmt from my SQL
connection = OpenShiftDerbySource.getConnection();
oStmt = connection.createStatement();
String sSQL = "SELECT * FROM PERSON";
ResultSet oRs = oStmt.executeQuery(sSQL);
System.out.println(ResultSetValue.toJsonString(oRs));
oRs.close();
}catch(Exception e){
e.printStackTrace();
}finally{
try{
if(oStmt != null) oStmt.close();
if(connection != null) connection.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
}

This is a simple select example that also makes use of a helper `ResultSetValue.toJsonString(oRs)`.