You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Jim Crowell <Ji...@EMail.com> on 2010/01/11 22:12:18 UTC

Derby Network Server usage?

Hello,

I have a Java [v1.5] stand alone application that creates a Derby Database. 
I implemented this application with Derby in the embedded mode. Works fine
so far!

I have a requirement to produce a series of reports given inputs from the
Derby Database. These reports shall be produced in two application modes as
follows:

	Mode APP:		From the Java stand alone application...
	Mode WWW:		From an Internet Browser...

Initially I intended to write the “Mode APP” Report Generator in Java
methods embedded within the Java stand alone application. 

In “Mode WWW” the Derby Database shall reside on a Server and the HTML shall
access the Derby Database  using JSP. The HTML shall enable my end user to
select a specific report, view the generated report and conditionally print
the report on-line.

To eliminate the need for 2 different report generators, ideally, I would
like to reuse the “Mode WWW” JSP in “Mode APP”, i.e. invoke my end user’s
default Internet Browser and process the reports via JSP acting-on the Derby
Database from the host computers HDD.

With the Derby Database presently being embedded, I believe that access to
the Derby HDD file from the Browser process will be denied.

Therefore, I will need to recode my application to setup three processes as
follows:

Process 1)	The Java stand alone application...
		.	Load the Derby Network Server in a new process
			[Process 2].
		.	Connect to the Derby Network Server...
		.	Create or Open the Derby Database file.
		.	Perform embedded services on the Database file.
		.	Conditionally spawn the default Internet Browser in a 
                        new process [Process 3] and invoke the Report
			Generator HTML.
Process 2)	The Derby Network Server...
Process 3)	The  Report Generator HTML...
		.	Connect to the Derby Server...
		.	Perform user authorization via account / password
               		user interface...
		.	Query the end user for report selection...
		.	Use the selected report template to produce a JSP
                        request to adjust the dynamic tags in the report
			template HTML...

NOTE 1:
The Java stand alone application shall be marketed for both the Windows and
the Mac OS X platforms...

NOTE 2:
The above assumptions suggest that the “Derby Network Server” can perform
JSP operations.
I doubt that is true.
I am thinking that I would need to have an Application Server [e.g. Tomcat]
included in the above scenario.

If an Application Server is required, can you please point me to a link to
help me understand what is required to implement this dual JSP usage from a
client computer?

WORKAROUND METHOD:

The re-use of the JSP in my host stand alone Java implementation may be more
work then I am capable of handling.

A workaround would be to write “Mode APP” unique HTML without JSP, i.e.
develop code to connect to the Derby Database file via the Derby Network
Server [Process 2] and emulate the JSP by making SQL queries and dynamically
changing the tags in the selected reports template HTML.

In this workaround I would hopefully reuse several Java methods from the
Java Servlets that service the JSP request in the “Mode WWW” processing.

HOUSEKEEPING:

I am concerned about the housekeeping required if I have to spawn the three
above processes [and perhaps a 4th for an Application Server].

I can close the processes properly when the Java stand alone application is
terminated by my end user. I assume that if the Java stand alone application
aborts unexpectedly, the additional processes will also be terminated by the
host Operation System.

Is that a safe assumption for both the Windows and Mac OS X platforms?

I am sorry for the wordiness of this inquiry.

I did not know how to better state my problem and my new Derby Database
design.

Please let me know where I have gone wrong and any better solutions to
implement my stated requirements. 


-----
Regards,
Jim...
-- 
View this message in context: http://old.nabble.com/Derby-Network-Server-usage--tp27117797p27117797.html
Sent from the Apache Derby Developers mailing list archive at Nabble.com.


Re: Derby Network Server usage?

Posted by Jim Crowell <Ji...@EMail.com>.
Bryan,

Thanks for all the help.

I just posted a message in the derby-user mailing list asking about the
feasibility of embedding a Web Server in my Java stand alone application.

The thread's subject is as follows:
"Embedded Web Server in Java stand alone application..."


Bryan Pendleton wrote:
> 
> Hi Jim,
> 
> These questions are probably better addressed to the derby-user mailing
> list
> since they have more to do with how to use Derby than with how it is
> implemented internally. So you probably want to pursue the discussion on
> that list, as you'll find more people who have experience building
> applications
> like the one you describe.
> 
> Derby does not provide a JSP container, nor a Servlet container, so if
> you are interested in writing JSPs and Servlets you'll need to find one.
> Tomcat is certainly a fine choice; there are plenty of other JSP and
> Servlet
> containers out there, but the derby-dev list is probably the wrong place
> to look
> for more information about that.
> 
> When you get to writing your JSPs and Servlets, you merely need to ensure
> that the derbyclient.jar library is available to them. In the case of most
> JSP or Servlet containers, there is a simple way to include such a jar
> library
> into your web application; for example in Tomcat I believe you just have
> to
> place derbyclient.jar into the correct 'lib' directory.
> 
> Once you have made derbyclient.jar available to your JSP or Servlet, you
> can
> simply create a new java.sql.Connection object in your code, using the
> Derby
> network-format URL scheme:
> 
>    jdbc:derby://host:port/databaseName;options
> 
> The ClientDriver class in the derbyclient.jar will then implement all of
> your
> JDBC calls using network access to the Network Server instance located in
> your application.
> 
> I think that JDK 1.5 is capable of doing everything you've described so
> far.
> I believe that JDK 1.6 adds further performance and functionality
> improvements,
> but Derby runs great with JDK 1.5 as well as with JDK 1.6 so you can
> choose
> whichever you prefer.
> 
> I believe you are correct that you don't need Java EE in order to write
> simple JSP and Servlet code. You just need J2SE and a Servlet/JSP
> container
> such as Tomcat.
> 
> I believe there is a great "using Derby with Tomcat" tutorial here:
> http://db.apache.org/derby/papers/fortune_tut.html
> There are some links in that tutorial to other Derby-with-Tomcat
> tutorials.
> 
> Good luck, and let us know if you run into any problems with Derby; the
> community will be glad to help.
> 
> thanks,
> 
> bryan
> 
> 
> 
> 


-----
Regards,
Jim...
-- 
View this message in context: http://old.nabble.com/Derby-Network-Server-usage--tp27117797p27148810.html
Sent from the Apache Derby Developers mailing list archive at Nabble.com.


Re: Derby Network Server usage?

Posted by Bryan Pendleton <bp...@amberpoint.com>.
Hi Jim,

These questions are probably better addressed to the derby-user mailing list
since they have more to do with how to use Derby than with how it is
implemented internally. So you probably want to pursue the discussion on
that list, as you'll find more people who have experience building applications
like the one you describe.

Derby does not provide a JSP container, nor a Servlet container, so if
you are interested in writing JSPs and Servlets you'll need to find one.
Tomcat is certainly a fine choice; there are plenty of other JSP and Servlet
containers out there, but the derby-dev list is probably the wrong place to look
for more information about that.

When you get to writing your JSPs and Servlets, you merely need to ensure
that the derbyclient.jar library is available to them. In the case of most
JSP or Servlet containers, there is a simple way to include such a jar library
into your web application; for example in Tomcat I believe you just have to
place derbyclient.jar into the correct 'lib' directory.

Once you have made derbyclient.jar available to your JSP or Servlet, you can
simply create a new java.sql.Connection object in your code, using the Derby
network-format URL scheme:

   jdbc:derby://host:port/databaseName;options

The ClientDriver class in the derbyclient.jar will then implement all of your
JDBC calls using network access to the Network Server instance located in
your application.

I think that JDK 1.5 is capable of doing everything you've described so far.
I believe that JDK 1.6 adds further performance and functionality improvements,
but Derby runs great with JDK 1.5 as well as with JDK 1.6 so you can choose
whichever you prefer.

I believe you are correct that you don't need Java EE in order to write
simple JSP and Servlet code. You just need J2SE and a Servlet/JSP container
such as Tomcat.

I believe there is a great "using Derby with Tomcat" tutorial here:
http://db.apache.org/derby/papers/fortune_tut.html
There are some links in that tutorial to other Derby-with-Tomcat tutorials.

Good luck, and let us know if you run into any problems with Derby; the
community will be glad to help.

thanks,

bryan



Re: Derby Network Server usage?

Posted by Jim Crowell <Ji...@EMail.com>.
Bryan,
Thanks for your excellent reply, very helpful.

I will implement the "Embedded Server" method described in the referenced
documentation.

I have a few additional questions if I may:

1) Where does the Web Server application reside?
I assume that I'll instance the Derby Network Server and I'll spawn the end
user default Internet Browser process with my Report Generator HTML. I know
what a Web Server does but I have never set one up or written any JSP /
Servlet code. Tomcat, I think is the best Web server for this
implementation. Is Tomcat and my JSP / Servlet code linked to the Derby
Network Server somehow?

2) My current Java stand alone application uses Java 1.5. A lot of the
documentation you pointed me to references Java 1.6. Is there a benefit for
me to upgrade to Java 1.6 before implementing this "Embedded Server" design?

3) I am using the Java 1.5 SE development system. The way I read todays
documents, I think I only need to go to the Java EE software development
system if I will be using Enterprise Java Bean in the JSP / Servlet code. Is
that correct?
    

Bryan Pendleton wrote:
> 
>> With the Derby Database presently being embedded, I believe that access
>> to
>> the Derby HDD file from the Browser process will be denied.
> 
> You can start the Network Server in a background thread in your embedded
> application, and your embedded application can access the database
> directly
> while simultaneously accepting and processing requests from network
> clients
> (for example, your JSPs in your web server). This mode of operation is
> usually called the "embedded server". You can find some documentation
> here:
> http://db.apache.org/derby/docs/10.5/adminguide/cadminov17524.html
> 
> There's a nice diagram of how this works here:
> http://db.apache.org/derby/papers/DerbyTut/ns_intro.html#Embedded+Server
> 


-----
Regards,
Jim...
-- 
View this message in context: http://old.nabble.com/Derby-Network-Server-usage--tp27117797p27134902.html
Sent from the Apache Derby Developers mailing list archive at Nabble.com.


Re: Derby Network Server usage?

Posted by Bryan Pendleton <bp...@amberpoint.com>.
> With the Derby Database presently being embedded, I believe that access to
> the Derby HDD file from the Browser process will be denied.

You can start the Network Server in a background thread in your embedded
application, and your embedded application can access the database directly
while simultaneously accepting and processing requests from network clients
(for example, your JSPs in your web server). This mode of operation is
usually called the "embedded server". You can find some documentation here:
http://db.apache.org/derby/docs/10.5/adminguide/cadminov17524.html

There's a nice diagram of how this works here:
http://db.apache.org/derby/papers/DerbyTut/ns_intro.html#Embedded+Server

thanks,

bryan