
Version: 2.18
Last Modified: 30. Mar 2012
The i-net KONNEKTER driver consists of two parts - the server and the client.?
The server is a multi-threaded Java API with integrated PoolManager. It receives queries from client drivers and forwards them to the appropriate local JDBC drivers for a particular data source. The results of the query processing is sent back to the client.
The client is a JDBC 2.0 driver that connects to the server over TCP/IP and accesses a database using a local JDBC driver for this database on the server. This allows to use one driver on the client site to access various databases over different drivers on the server site.
The server requires:
The client requires:
Extract the driver jar file from the zip file you have purchased or downloaded. The name of the jar file is like the drivername. It can be:
Add the file Konnekter_Server.jar to your classpath or extract the jar file in the directory of the application.
Here is the simplest example of the server application.
import com.inet.jj.srv.*; // imports the server's package import java.sql.*; public class AppServer { public static void main(String[] args) { // Loads the drivers using by application. try{ Class.forName("com.inet.tds.TdsDriver"); Class.forName("com.inet.ora.OraDriver"); //.... }catch(Exception ex){ ex.printStackTrace(); } // Instances the server listening to the default port 9876. JJServer srv = new JJServer(); // Enables server debugging to the "standard" output. srv.setLogStream(System.out); // Enables the debugging of JDBC drivers running on the server. DriverManager.setLogStream(System.out); // Starts the server. srv.start(); } }
See also the file samples/AppServer.java
See the API Documentation.
For using the driver in a java application add the file Konnekter_Client.jar to your classpath or extract the jar file in the directory of the application.
For using the driver in an applet add the file Konnekter_Client.jar to the Archive attribute of the applet tag, e.g.:
<APPLET CODE="..." Codebase="..." ARCHIVE="Konnekter_Client.jar" WIDTH="100%" HEIGHT="100%"> ... </APPLET>
or extract the jar in the directory of the applet.
The class name of the driver is: com.inet.jj.cli.JJDriver
jdbc:inetjj:host[:port][?loglevel=warning];driverURL jdbc:inetjj:http://proxy-address[[?server=host]&port=port][&loglevel=warning];driverURL jdbc:inetjj:host[:port][?loglevel=warning];UDS jdbc:inetjj:http://proxy-address[[?server=host]&port=port][&loglevel=warning];UDS
| host | the host name on which the server is running |
| port | the port number(by default 9876) |
| driverURL | the url for the required driver on the server |
| UDS | the User Data Source name which was defined on the server |
| proxy-address | the URL of the Konnekter proxy. This can be the proxy.dll in the IIS or the proxy.jsp in a servlet engine or proxy.php for the Apache. The default values for server is LocalHost and port is 9876. |
| loglevel | Enable a logging independent of the JDBC logging to System.out. The only valid value is “warning”. Currently only a reconnect is logging. |
If you use the url of the required driver directly then you can put additional properties (e.g., user, password, etc.) to this driver on the server using methods of DriverManager
For examples:
import java.sql.*; // JDBC package ... String url = "jdbc:inetjj:<host>;<driver url>"; // use your host name and driver url here ... try { // to create more info for technical support DriverManager.setLogStream(System.out); //set a timeout for login and query DriverManager.setLoginTimeout(15); //load the class with the driver Class.forName("com.inet.jj.cli.JJDriver"); //open a connection to the database Connection connection = DriverManager.getConnection(url); //to get the driver version DatabaseMetaData conMD = connection.getMetaData(); System.out.println("Driver Name:\t" + conMD.getDriverName()); System.out.println("Driver Version:\t" + conMD.getDriverVersion()); //create a statement Statement st = connection.createStatement(); //execute a query ResultSet rs = st.executeQuery("SELECT * FROM tblExample"); // read the data and put it to the console while (rs.next()){ for(int j=1; j<=rs.getMetaData().getColumnCount(); j++){ System.out.print( rs.getObject(j)+"\t"); } System.out.println(); } //close the objects st.close(); connection.close(); } catch(Exception e) { e.printStackTrace(); } ...
See also the file samples/AppClient.java
If the client runs in Java 1.1.x environment (e.g., in an applet) you can also use JDBC 2.0 methods using the “true” class names instead of interface names. The classes are called JJXXX, where XXX represents the name of the corresponding interface.
For example:
... JJConnection con = (JJConnection)DriverManager.getConnection("..."); Statement st = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); JJResultSet rs = (JJResultSet)st.executeQuery("select * from jjtest"); int count = rs.getMetaData().getColumnCount(); rs.afterLast(); while(rs.previous()) { for(int i = 1; i <= count; i++) System.out.print(rs.getObject(i)); } ...
Note: The methods getClob() and getBlob() can be used in JDBC 2.0 only.
See the API Documentation.
To enable the logging of the driver you can use the static method of the DriverManager class with PrintStream as argument:
DriverManager.setLogStream( System.out ); //logging on the standard output stream DriverManager.setLogStream( System.err ); //logging on the standard error output stream //logging in a file DriverManager.setLogStream( new PrintStream( new FileOutputStream( "driver.log" ) ) );
If you want use port 80 with i-net KONNEKTER but you can't use the port 80 because the port is already in use from your web server then you can use a proxy. The using of port 80 is recommended for the internet. Many internet user can only use port 80.
Deploy the proxy.jsp file in your JSP engine (for example Tomcat). This file can you find? in the proxy folder of the download zip file. See the description of your JSP engine for detail of deploying.
If you want use Konnekter with Apache or another PHP supported web server then you need:
The Commands are SQL statements stored on the server. Each command has its unique name and can be added to the current command list with the method addCommand(command_name, sql_statement) from the JJServer. Each client can access a command by its name and according SQL statement will be executed on the server.
For example, to create a query command like “select * from myTable” do following:
// assuming that srv is a instance of JJServer srv.addCommand("Query 1", "select * from myTable");
Now can a client execute this command passing its name to the server:
// we need to cast because the executeQueryCommand method is not the JDBC API JJStatement jjst = (JJStatement)con.createStatement(); ResultSet rs = jjst.executeQueryCommand("query 1");
That works also with a PreparedStatement:
// adds the command on the server srv.addCommand("cmd1", "insert into table1 values (?)");
Now call this command on the client:
// assuming that con is a valid JJConnection. // the client needs to know the number of parameters PreparedStatement pst = ((JJConnection)con).prepareCommand("cmd1", 1); pst.setString(1, "trtrt"); pst.execute();
Note: the command names are not case sensitive.
For more info see the API documentation.
The Named Parameters are a additionally functionality of the i-net Konnekter. You can define on the server a command contained the named parameters and set they on the client using the method setObject(String paramName, Object value) from JJPreparedStatement. The server is responsible to pass the parameters in the right order.
The syntax: each named parameter containing in the SQL statement must be terminated by '%' character.
For example:
// adds on the server a command containing the named parameters 'param1' and 'param2' srv.addCommand("cmd", "update tabl1 set col1=%param1% where col2 > %param2%"); //on the client we need to cast the java.sql interfaces to the "right" objects JJPreparedStatement pst = (JJPreparedStatement)((JJConnection)con).prepareCommand("cmd", 2); // set the parameter, the parameter order doesn't matter pst.setObject("param2", new Integer(100)); pst.setObject("param1", "trtrt"); pst.execute();
Note: the parameter names are not case sensitive.
For more info see the API documentation.
The JavaCommands are a extension of the server commands. The JavaCommand object will be created on the server if the client calls the method prepareCommand() or prepareCallCommand() from the JJConnection with a command name which corresponded to a special JavaCommandFactory object stored in the current command list (like a sql command) on the server.
As a JavaCommandFactory object has been added to the command list all client's calls of the method prepareCommand() or prepareCallCommand() will be redirected to the corresponding methods of the JavaCommandFactory object which will create a new JavaCommand object referenced to an object (JJPreparedStatement or JJCallableStatement) on the client. After that all client's request from the corresponding object will be redirected to the JavaCommand object on the server.
The class JavaCommandFactory contains four method corresponded to the JJConnection methods:
prepareCommand(Connection con), prepareCommand(Connection con, int rsType, rsConcur) prepareCallCommand(Connection con) prepareCallCommand(Connection con, int rsType, rsConcur)
where con is a “real” connection to the database.
The methods throw a SQLException and must be overridden by extended objects. All that methods return a new JavaCommand object.
The class JavaCommand implements the java.sql.CallableStatement interface and one additionally method getObject(String, String) that corresponded to the method in JJPreparedSatatement and using for passing named parameters. The methods do nothing and should be overridden by extended objects.
To use JavaCommands in your application you should only extend the JavaCommand and the JavaCommandFactory classes and use that instance in the corresponding methods.
For more info see the API documentation and the samples samples/MyCommand.java and samples/MyCommandFactory.java.
Please read this file and our FAQ
If you cannot find your problem in the FAQ then post your problem to our newsgroup providing as much information about what occured or happened as possible. You can find more info about our support at http://www.inetsoftware.de/support
Copyright by i-net software
More info and updates can be found at http://www.inetsoftware.de/
© 2000-2011 i-net software