com.apelon.apelonserver.client
Class ServerConnectionJDBC

java.lang.Object
  extended by com.apelon.apelonserver.client.ServerConnection
      extended by com.apelon.apelonserver.client.ServerConnectionJDBC

public class ServerConnectionJDBC
extends ServerConnection

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.

The 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);

Version:
1.0.0
Author:
Apelon, Inc.
See Also:
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

ServerConnectionJDBC

public ServerConnectionJDBC(String user,
                            String password,
                            String host,
                            int port,
                            String dbname)
Establish a connection to a local JDBC connection.

Parameters:
user - the user name
password - the user's password
host - host name to connect to
port - datbase port to connect
dbname - database name or instance

ServerConnectionJDBC

public ServerConnectionJDBC(String user,
                            String password,
                            String host,
                            int port,
                            String dbname,
                            int maxDbConn)
Deprecated. 

Establish a connection to a local JDBC connection.

Parameters:
user - the user name
password - the user's password
host - host name to connect to
port - database port to connect
dbname - database name or instance
maxDbConn - maximum database connections

ServerConnectionJDBC

public ServerConnectionJDBC(com.apelon.common.sql.ConnectionParams params)
Parameters:
params -

ServerConnectionJDBC

public ServerConnectionJDBC(com.apelon.apelonserver.server.RemoteServerJDBC rs)
Deprecated. instead use ServerConnectionJDBC(String user, String password, String host, int port, String dbname)

Establish a connection to a local JDBC connection.

Parameters:
rs - RemoteServerJDBC instance. this provides jdbc connection to send a query to the database
Method Detail

executeQueryRemote

protected String executeQueryRemote(String query)
This method prepend the query to query header and sends the query to a proper query server pool. The query header is set by serverConnection which is set by BasicQuery.

Specified by:
executeQueryRemote in class ServerConnection
Parameters:
query - information to be sent to remoteServerJDBC
Returns:
result of the query

setQueryServer

public void setQueryServer(Class qs,
                           String header)
                    throws ClassNotFoundException
This method creates the query server pool and sets a type of query server and assicates query server with header. This method is used in multiple RemoteJDBC connection to set up the multiple query server

Overrides:
setQueryServer in class ServerConnection
Parameters:
qs - class query server class
header - query server header to be assoicated with query server class.
Throws:
ClassNotFoundException - thrown if there is no query server class

setQueryServer

public void setQueryServer(Class qs,
                           String header,
                           String[] app_args)
                    throws ClassNotFoundException
Throws:
ClassNotFoundException

close

public void close()
           throws Exception
Description copied from class: ServerConnection
Close the connection

Overrides:
close in class ServerConnection
Throws:
Exception - thrown if there is an error during close of server connection

toString

public 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. We just return the RemoteServerJDBC toString() method return.

Overrides:
toString in class Object
Returns:
java.lang.String


Copyright © 2011. All Rights Reserved.