|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.apelon.apelonserver.client.ServerConnection
com.apelon.apelonserver.client.ServerConnectionJDBC
public class ServerConnectionJDBC
A ServerConnectionJDBC permits a basic JDBC connection directly to the
database and avoids the need to create a socket based server.
This is very useful during program development and for small demos.
setQueryServer(java.lang.Class, java.lang.String) method is requred to be called to set the
supporting server side class that will process query calls. This
step requires the programmer to know which server class to pass along with
the required query server header. A header is a seven character key that
allows the ApelonServer to couple request to server objects. Since the
ApelonServer is not required when using a JDBC connection this link must
be established by calling setQueryServer().
The following is the example of how to create each of the query objects
available in the DTS API using a JDBC connection.
This example creates a ServerConnectionJDBC instance, sets the server
classes, sets the query headers and creates an instance of each query object.
ServerConnectionJDBC jdbcConnection =
new ServerConnectionJDBC("user", "pass", "host", 1521, "dbname");
// Namespace
jdbcConnection.setQueryServer(
Class.forName("com.apelon.dts.server.NamespaceServer"),
com.apelon.dts.client.common.DTSHeader.NAMESPACESERVER_HEADER);
NamespaceQuery namespaceQuery =
(NamespaceQuery) NamespaceQuery.createInstance(jdbcConnection);
// Association
jdbcConnection.setQueryServer(
Class.forName("com.apelon.dts.server.AssociationServer"),
com.apelon.dts.client.common.DTSHeader.ASSOCIATIONSERVER_HEADER);
AssoicationQuery associationQuery =
(AssociationQuery) AssociationQuery.createInstance(jdbcConnection);
// Search
jdbcConnection.setQueryServer(
Class.forName("com.apelon.dts.server.SearchQueryServer"),
com.apelon.dts.client.common.DTSHeader.SEARCHSERVER_HEADER);
SearchQuery searchQuery =
(SearchQuery) SearchQuery.createInstance(jdbcConnection);
// OntylogConcept
jdbcConnection.setQueryServer(
Class.forName("com.apelon.dts.server.OntylogConceptServer"),
com.apelon.dts.client.common.DTSHeader.ONTYLOGCONCEPTSERVER_HEADER);
OntylogConceptQuery conceptQuery =
(OntylogConceptQuery) OntylogConceptQuery.createInstance(
jdbcConnection);
// DTSConcept
jdbcConnection.setQueryServer(
Class.forName("com.apelon.dts.server.DTSConceptServer"),
com.apelon.dts.client.common.DTSHeader.DTSCONCEPTSERVER_HEADER);
DTSConceptQuery conceptQuery =
(DTSConceptQuery) DTSConceptQuery.createInstance(jdbcConnection);
// NavQuery
jdbcConnection.setQueryServer(
Class.forName("com.apelon.dts.server.NavQueryServer"),
com.apelon.dts.client.common.DTSHeader.NAVSERVER_HEADER);
NavQuery navQuery =
(NavQuery) NavQuery.createInstance(jdbcConnection);
// ThesaurusConcept
jdbcConnection.setQueryServer(
Class.forName("com.apelon.dts.server.ThesaurusConceptServer"),
com.apelon.dts.client.common.DTSHeader.THESAURUSCONCEPTSERVER_HEADER);
ThesaurusConceptQuery navQuery =
(ThesaurusConceptQuery) ThesaurusConceptQuery.createInstance(
jdbcConnection);
// Term
jdbcConnection.setQueryServer(
Class.forName("com.apelon.dts.server.TermServer"),
com.apelon.dts.client.common.DTSHeader.TERMSERVER_HEADER);
// TermSearchQuery and TermQuery both use the TermServer
TermQuery TermQuery =
(TermQuery) TermQuery.createInstance(jdbcConnection);
TermQuery TermQuery =
(TermQuery) TermQuery.createInstance(jdbcConnection);
// Match
jdbcConnection.setQueryServer(
Class.forName("com.apelon.dts.server.MatchServer"),
com.apelon.dts.client.common.DTSHeader.MATCHSERVER_HEADER);
MatchQuery matchQuery =
(MatchQuery) MatchQuery.createInstance(jdbcConnection);
// License
jdbcConnection.setQueryServer(
Class.forName("com.apelon.dts.server.DTSLicenseServer"),
com.apelon.dts.client.common.DTSHeader.LICENSESERVER_HEADER);
LicenseQuery licenseQuery =
DTSLicenseQuery.createInstance(jdbcConnection);
RemoteServerJDBC| Constructor Summary | |
|---|---|
ServerConnectionJDBC(com.apelon.common.sql.ConnectionParams params)
|
|
ServerConnectionJDBC(com.apelon.apelonserver.server.RemoteServerJDBC rs)
Deprecated. instead use ServerConnectionJDBC(String user, String password, String host, int port, String dbname) |
|
ServerConnectionJDBC(String user,
String password,
String host,
int port,
String dbname)
Establish a connection to a local JDBC connection. |
|
ServerConnectionJDBC(String user,
String password,
String host,
int port,
String dbname,
int maxDbConn)
Deprecated. |
|
| Method Summary | |
|---|---|
void |
close()
Close the connection |
protected String |
executeQueryRemote(String query)
This method prepend the query to query header and sends the query to a proper query server pool. |
void |
setQueryServer(Class qs,
String header)
This method creates the query server pool and sets a type of query server and assicates query server with header. |
void |
setQueryServer(Class qs,
String header,
String[] app_args)
|
String |
toString()
Put this method in so that we can call toString on the server connection and retrieve a nice string to place into a status area about the user, and host we are connected to. |
| Methods inherited from class com.apelon.apelonserver.client.ServerConnection |
|---|
ping |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ServerConnectionJDBC(String user,
String password,
String host,
int port,
String dbname)
user - the user namepassword - the user's passwordhost - host name to connect toport - datbase port to connectdbname - database name or instance
public ServerConnectionJDBC(String user,
String password,
String host,
int port,
String dbname,
int maxDbConn)
user - the user namepassword - the user's passwordhost - host name to connect toport - database port to connectdbname - database name or instancemaxDbConn - maximum database connectionspublic ServerConnectionJDBC(com.apelon.common.sql.ConnectionParams params)
params - public ServerConnectionJDBC(com.apelon.apelonserver.server.RemoteServerJDBC rs)
rs - RemoteServerJDBC instance. this provides jdbc connection to
send a query to the database| Method Detail |
|---|
protected String executeQueryRemote(String query)
executeQueryRemote in class ServerConnectionquery - information to be sent to remoteServerJDBC
public void setQueryServer(Class qs,
String header)
throws ClassNotFoundException
setQueryServer in class ServerConnectionqs - class query server classheader - query server header to be assoicated with query server
class.
ClassNotFoundException - thrown if there is no query server class
public void setQueryServer(Class qs,
String header,
String[] app_args)
throws ClassNotFoundException
ClassNotFoundException
public void close()
throws Exception
ServerConnection
close in class ServerConnectionException - thrown if there is an error during close of server
connectionpublic String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||