import java.util.*; import java.sql.*; public class LoadUpdateAPI { // Change the following values to meet your settings // --- public static String apiLocation = "/usr/local/lib/rql-spi-api.so"; public static String dblocation = "localhost:5432"; public static String dbname = "apitest"; public static String username = "saxtouri"; public static String password = ""; // --- public static void main(String[] args) { String query = ""; try { Class.forName("org.postgresql.Driver"); } catch(java.lang.ClassNotFoundException ex) { System.out.println(ex.getMessage()+ ": PostgreSQL driver is not found. \nCheck if the CLASSPATH variable contains the postgresql.jar path."); } //change dbURL to reflect the machine/port postmaster is running and //the name of your db String dbURL = "jdbc:postgresql://"+dblocation+"/"+dbname; Properties info = new Properties(); info.setProperty("user", username); info.setProperty("password", password); try { Connection con = DriverManager.getConnection(dbURL, info); //begin the transaction con.setAutoCommit(false); Statement stmt = con.createStatement(); ResultSet rs = null; int retVal = -1; // load create_instance query = "create function create_instance(text,text,text) returns int4 as '"+apiLocation+"' language 'c'"; System.out.println("Executing query:\n\t"+query); try{stmt.executeQuery(query);} catch(SQLException e1){} // load delete_object query ="create function delete_object(text, text, text, int4) returns int4 as '"+apiLocation+"' language 'c'"; System.out.println("Executing query:\n\t"+query); try{rs = stmt.executeQuery(query);} catch(SQLException e1){} // load add_property query ="create function add_property(text, text, text, text) returns int4 as '"+apiLocation+"' language 'c'"; System.out.println("Executing query:\n\t"+query); try{rs = stmt.executeQuery(query);} catch(SQLException e1){} // load delete_property query ="create function delete_property(text, text, text, text, int4) returns int4 as '"+apiLocation+"' language 'c'"; System.out.println("Executing query:\n\t"+query); try{rs = stmt.executeQuery(query);} catch(SQLException e1){} // load update_property query ="create function update_property(text, text, text, text, text, int4) returns int4 as '"+apiLocation+"' language 'c'"; System.out.println("Executing query:\n\t"+query); try{rs = stmt.executeQuery(query);} catch(SQLException e1){} //commit the transaction con.commit(); System.out.println("Transaction committed!"); if (stmt != null) stmt.close(); } catch(SQLException ex) { System.out.println("SQLException: " + ex.getMessage()); ex.printStackTrace(); } } }