How do you connect to a JDataStore?

Abstract: How do you connect to a JDataStore?

Using the JDBC API:

String driverName = "com.borland.datastore.jdbc.DataStoreDriver";
String dataStoreName = "fileName.jds";
String url = "jdbc:borland:dslocal:" + dataStoreName;

Class.forName(driverName);
Connection con = DriverManager.getConnection(url, "userName", "");

DataExpress users will be familiar with the code snippet below.
Part of it can be generated automatically while setting up the Connection property of a Database component:

ConnectionDescriptor con =
new ConnectionDescriptor("jdbc:borland:dslocal:storeName.jds",
"userName",
"pwd",
false,
"com.borland.datastore.jdbc.DataStoreDriver");
db.setConnection(con);
db.openConnection();

For Remote stores, the URL should be in the format below:

"jdbc:borland:dsremote://hostName/path/storeName.jds"

For example, on a Windows system you could use the following URL to access a store in your own machine using the remote JDBC DataStore driver:

"jdbc:borland:dsremote://localhost/c:/stores/myStore.jds"

On a *nix system, the following URL will connect to a store located at /usr/local/datastores, notice the double
slash after the machine name.

"jdbc:borland:dsremote://unixBox//usr/local/datastores/store.jds"

You can also use a relative path based on the working directory of the current Java Virtual Machine.