Table of Contents
The following description shows you how you can write a Java client
program for connect a DataStore database using the DataStore self-driver
for connection. This program is an example for store data into DataStore,
using authentication and secure connection.
To write DataStore client programs you need the following libraries:
-
beepcore.jar
-
beepsasl.jar
-
beeptls-jsse.jar
-
beeptls-ptls.jar
-
cryptix32.jar
-
cryptix-asn1.jar
-
datastore.jar
-
jcert.jar
-
jnet.jar
-
jsse.jar
-
puretls.jar
-
xerces.jar
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import org.media.datastore.sepengine.driver.beepDriver.*;
import org.media.datastore.sepengine.driver.*;
public class Store {
public static void main( String[] argv ) {
}
}
|
|
On the first the connection con will be null. The url
variable is a path for a connection, where the localhost is a hostname,
the 10288 is the port number, XMLDB the symbolic name of
the database. The security you don't need to use, only if you want a
secure connection. The default user is guest and the password
is guest
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import org.media.datastore.sepengine.driver.beepDriver.*;
import org.media.datastore.sepengine.driver.*;
public class Store {
static SepStoreConnection con = null;
static String url = "sep:beep://localhost:10288/XMLDB;security=jsse";
static String user = "guest";
static String passwd = "guest";
public static void main( String[] argv ) {
}
}
|
|
The SEP command will be stored into the string, named sep. This
command will store a small block person into the database, into the
subtree named test.
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import org.media.datastore.sepengine.driver.beepDriver.*;
import org.media.datastore.sepengine.driver.*;
public class Store {
static SepStoreConnection con = null;
static String url = "sep:beep://localhost:10288/XMLDB;security=jsse";
static String user = "guest";
static String passwd = "guest";
static String sep = "<store action='write'>"+
"<block name='test'>" +
"<person>\n"+
" <name first='Antal' last='Attila'/>\n"+
" <occupation>developer</occupation>\n"+
" <email>atech@nolimits.ro</email>\n"+
"</person>"+
"</block>" +
"</store>\n";
public static void main( String[] argv ) {
}
}
|
|
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import org.media.datastore.sepengine.driver.beepDriver.*;
import org.media.datastore.sepengine.driver.*;
public class Store {
static SepStoreConnection con = null;
static String url = "sep:beep://localhost:10288/XMLDB;security=jsse";
static String user = "guest";
static String passwd = "guest";
static String sep = "<store action='write'>"+
"<block name='test'>" +
"<person>\n"+
" <name first='Antal' last='Attila'/>\n"+
" <occupation>developer</occupation>\n"+
" <email>atech@nolimits.ro</email>\n"+
"</person>"+
"</block>" +
"</store>\n";
public static void main( String[] argv ) {
try {
System.setProperty( "sep.drivers",
"org.media.datastore.sepengine.driver.beepDriver.BeepDriver");
}
catch ( Exception e ) {
System.err.println( "Error: " + e.getMessage() );
}
}
}
|
|
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import org.media.datastore.sepengine.driver.beepDriver.*;
import org.media.datastore.sepengine.driver.*;
public class Store {
static SepStoreConnection con = null;
static String url = "sep:beep://localhost:10288/XMLDB;security=jsse";
static String user = "guest";
static String passwd = "guest";
static String sep = "<store action='write'>"+
"<block name='test'>" +
"<person>\n"+
" <name first='Antal' last='Attila'/>\n"+
" <occupation>developer</occupation>\n"+
" <email>atech@nolimits.ro</email>\n"+
"</person>"+
"</block>" +
"</store>\n";
public static void main( String[] argv ) {
try {
System.setProperty( "sep.drivers",
"org.media.datastore.sepengine.driver.beepDriver.BeepDriver");
con = SepStoreDriverManager.getConnection(url, user, passwd);
con.close();
}
catch ( Exception e ) {
System.err.println( "Error: " + e.getMessage() );
}
}
}
|
|
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import org.media.datastore.sepengine.driver.beepDriver.*;
import org.media.datastore.sepengine.driver.*;
public class Store {
static SepStoreConnection con = null;
static String url = "sep:beep://localhost:10288/XMLDB;security=jsse";
static String user = "guest";
static String passwd = "guest";
static String sep = "<store action='write'>"+
"<block name='test'>" +
"<person>\n"+
" <name first='Antal' last='Attila'/>\n"+
" <occupation>developer</occupation>\n"+
" <email>atech@nolimits.ro</email>\n"+
"</person>"+
"</block>" +
"</store>\n";
public static void main( String[] argv ) {
try {
System.setProperty( "sep.drivers",
"org.media.datastore.sepengine.driver.beepDriver.BeepDriver");
con = SepStoreDriverManager.getConnection(url, user, passwd);
InputStreamReader response = new InputStreamReader(con.executeSEP(sep));
BufferedReader reader = new BufferedReader( response );
String line = null;
while ( ( line = reader.readLine() ) != null )
System.out.println(line);
con.close();
}
catch ( Exception e ) {
System.err.println( "Error: " + e.getMessage() );
}
}
}
|
|