// JDBC IDL -- sample call to the JDBC through IDL package TestIDL; import java.sql.*; public class JIImpl extends _JIImplBase { private JIConnection jic [] = new JIConnection [5]; /** Default constructor */ public JIImpl (){ } /** Method to open a database connection */ public synchronized int openDatabase() { int connectionId; // Loop through connection table until an empty slot is found for (connectionId = 0; connectionId < jic.length; connectionId++) { if (jic [connectionId] == null) break; } // If no empty slots found, generate an error if (connectionId >= jic.length) { System.out.println("Out of connection objects."); return -1; } // Create a connection for the new process and run it jic [connectionId] = new JIConnection(); // Call the new connection's method to open a database connection try { jic[connectionId].openDatabase(); } catch (Exception e) { connectionId = -1; } // return the connection identifier return connectionId; } /** Issue a SQL query with a WHERE clause */ public void performSearch(int id, String searchString) { try { jic[id].performSearch(searchString); } catch (Exception e) {} } /** Fetch the next row from the current query result */ public String getNextRow(int id) { String s = null; try { s = jic[id].getNextRow(); } catch (Exception e) {} return s; } /** Close the database connection */ public void closeDatabase(int id) { try { jic[id].closeDatabase(); jic[id] = null; } catch (Exception e) {} } }