![]() |
Embedding Servers
|
|
How to Start an Embedded Server From an ApplicationIn one thread, the embedding application boots the local JDBC driver for its own access. /* loading the client driver boots the client driver only*/ Class.forName("COM.cloudscape.core.JDBCDriver").newInstance(); Connection conn = DriverManager.getConnection( "jdbc:cloudscape:toursDB;autocommit=true"); In another thread the same application boots the server framework to allow remote access. Booting the server framework from within the application allows it to run in the same JVM as the application. RmiJdbc Server ExampleInstead of booting the server framework on the command line, the application boots the server framework programmatically: /* you could set any needed RmiJdbc properties as system properties here*/ myargs = new String[1]; myargs[0] = "COM.cloudscape.core.JDBCDriver"; System.out.println( RmiJdbc.RJJdbcServer.main(myargs)); The server framework's attempt to boot the local JDBC driver is redundant and ignored, because it has already been booted within the framework's JVM. The server framework simply accesses the instance of Cloudscape already booted; there is no conflict between the application and the server framework. The remote client can then connect via the client driver: Connection conn = DriverManager.getConnection( "jdbc:cloudscape:rmi://localhost:1099/toursDB"); /* interact with Cloudscape */ Statement s = conn.createStatement(); ResultSet rs = s.executeUpdate( "DELETE FROM HotelBookings WHERE booking_date < current_date"); Cloudconnector ExampleInstead of booting the server framework on the command line, the application boots the server framework programmatically: // set any needed properties before booting Cloudconnector: // you may also want to set weblogic.system.home Remote Cloudconnector clients connect using the Cloudconnector client driver and database connection URL: /* remote WebLogic clients connect using the WebLogic driver and URL*/ Connection conn = DriverManager.getConnection( " jdbc:cloudscape:weblogic:toursDB"; Because Cloudconnector is also an HTTP server, no additional configuration is needed to allow servlet access. Servlets are also embedded in Cloudconnector, which is embedded in the same JVM as Cloudscape, and so servlet access to Cloudscape can be through the local JDBC driver, which is already booted. |
|
![]() Cloudscape Version 3.6 For information about Cloudscape technical support, go to: www.cloudscape.com/support/.Copyright © 1998, 1999, 2000 Informix Software, Inc. All rights reserved. |