|
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Class Summary | |
---|---|
AbstractConnection | Provides default implementations for the Connection interface. |
AbstractDriver | Provides default implementations for the Driver interface. |
AbstractStatement | Provides default implementations for the Statement interface. |
MVConnection | Implements connection methods for an MV server. |
MVConstants | Defines constants used by the MVAPI |
MVDriver | Implements driver methods for an MV driver. |
MVIndex | Provides access to Multivalue file indexes. |
MVStatement | Provides methods for executing commands and calling subroutines on the server. |
MVSubroutine | Encapsulates a subroutine. |
Enum Summary | |
---|---|
MVConstants.LicenseType | Enumeration of the allowable license types. |
A package containing the MVAPI classes.
MVAPI is an application programming interface enabling developers using the Java programming language to access data stored in mutlivalued databases.
The MVAPI contains connection, statement and resultset objects to allow connecting to a multivalued database, executing queries and processing the results.
Example usage:
import com.rocketsoftware.mvapi.MVConnection; import com.rocketsoftware.mvapi.MVStatement; import com.rocketsoftware.mvapi.MVConstants; import com.rocketsoftware.mvapi.ResultSet.MVResultSet; import com.rocketsoftware.mvapi.exceptions.MVException; import java.util.Properties; /** * Demonstrates using MVAPI to connect to a D3 Server, execute queries and return the results. */ public class Main { public static void main(String [] args) { Properties props = new Properties(); props.setProperty("username", "dm"); props.setProperty("password", ""); String url = "jdbc:mv:d3:localhost:9003"; String account = "MVTest"; String AM = MVConstants.AM; String query; MVConnection connection = null; try { connection = new MVConnection(url, props); /** * Execute a query and display the results: */ MVStatement mvStatement = connection.createStatement(); connection.logTo(account, ""); query = "LIST CUSTOMERS ID NAME ADDRESS CITY STATE ZIP PHONE BALANCE (I"; boolean result = mvStatement.execute(query); MVResultSet results = mvStatement.getResultSet(); while (results.next()) { String row = results.getCurrentRow(); System.out.println(row); } /** * Call a subroutine passing it some values then read the results: */ /** * subroutine name: */ String subname = "hello"; /** * Subroutine parameters: */ String parameters = "X" + AM + "Y" + AM + "Z"; query = subname + AM + parameters; mvStatement.execute(query); /** * subroutine source on server: subroutine hello(indata, outdata) no.of.parameters = dcount(indata, @am) outdata = 'parameters = ':no.of.parameters outdata = outdata:@am:indata return * */ /** * result set from the subroutine is the OUTDATA dynamic * array with each attribute generating one row in the result set. */ results = mvStatement.getResultSet(); while (results.next()) { String row = results.getCurrentRow(); System.out.println(row); } } catch (MVException e) { e.printStackTrace(); } finally { if (connection != null) { try { connection.close(); } catch (MVException e) { e.printStackTrace(); } } } } /** * Demonstrates using the MVStatement executeQuery with selection and sort criteria. */ public void demo_executeQuery() { Properties props = new Properties(); props.setProperty("username", "dm"); props.setProperty("password", ""); String url = "jdbc:mv:d3:localhost:9000"; MVConnection connection = null; try { // Open the connection. // -------------------- connection = new MVConnection(url, props); MVStatement mvStatement = connection.createStatement(); // Log to the account, execute the query and return the result set. // ---------------------------------------------------------------- connection.logTo("SQLDEMO", ""); MVResultSet results = mvStatement.executeQuery( "CUSTOMERS", // file name "WITH STATE = \"California\"", // selection criteria "BY ORGANIZATIONNAME", // sort order "CUSTOMERID ORGANIZATIONNAME ADDRESS CITY STATE", // results ""); // no specific Item-Ids // Display column names. // --------------------- for (int i=0;i<results.getColumnCount();i++) { System.out.println(i + " " + results.getColumns()[i] + " "); } // Display rows. // ------------- while (results.next()) { System.out.println(results.getCurrentRow()); } } catch (MVException e) { e.printStackTrace(); } } /** * Demonstrates calling a subroutine using the MVSubroutine object. */ public void sub_call() throws MVException { Properties props = new Properties(); props.setProperty("username", "dm"); props.setProperty("password", ""); String url = "jdbc:mv:d3:localhost:9000"; MVConnection connection = null; try { connection = new MVConnection(url, props); connection.logTo("MVDEMO", ""); // This subroutine takes 3 arguments. // ---------------------------------- String subName = "TEST.SUBROUTINE"; int arguments = 3; MVSubroutine mvSubroutine = connection.mvSub(subName, arguments); System.out.println("name: " + mvSubroutine.getName() ); // Set the argument values. // ------------------------ mvSubroutine.setArg(0, "aaa"); mvSubroutine.setArg(1, "bbb"); mvSubroutine.setArg(2, "ccc"); // Call the subroutine. // -------------------- mvSubroutine.mvCall(); // Display the values returned. // ---------------------------- for (int i=0;i<arguments;i++) { System.out.println(mvSubroutine.getArg(i)); } } finally { if (connection != null) { try { connection.close(); } catch (MVException e) { e.printStackTrace(); } } } } }
|
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |