How to supply a Database enabled Application?

A

Atharvan :-)

hi
I am recently covered JavaIntro course of Javawithpassion.com, ie.,
I'm
a newbie.
Now I decided to write an application which uses a Data Base and opt
firebird because it's very small ( < 5mb ).

My doubt is that whether I need to supply firebird together with my
application to function it. ( I am using Linux but many of my friends
using windows. That's why I choose java.) Or Is the required modules
included in the package itself so I don't need to give it seperatly.
( I am using NetBeans IDE )

Please replay me considering this Question as childish.

Arun.K.R

!Atharvan!333!
{Man can be Destroyed but CANNOT be Defeated}
 
S

Stefan Ram

Atharvan :-) said:
Please replay me considering this Question as childish.

I am attaching my own similar question:

How much could the success of a Java application be
reduced, when one requires the target site to install
the JDK instead of the JRE?

For example, this would give applications a database
(Derby) and Java could be used as a scripting
language for such an applications (via the compiler API).
 
L

Lord Zoltar

Atharvan said:
hi
I am recently covered JavaIntro course of Javawithpassion.com, ie.,
I'm
a newbie.
Now I decided to write an application which uses a Data Base and opt
firebird because it's very small ( < 5mb ).

My doubt is that whether I need to supply firebird together with my
application to function it. ( I am using Linux but many of my friends
using windows. That's why I choose java.) Or Is the required modules
included in the package itself so I don't need to give it seperatly.
( I am using NetBeans IDE )

Please replay me considering this Question as childish.

Arun.K.R

!Atharvan!333!
{Man can be Destroyed but CANNOT be Defeated}

I'm not sure I understand when you say you are using the Firebird
database. Do you mean that you will access the same database files
that Firebird does? If that's the case, your program would have to
search for the files or re-create them (if they don't exist), but
maybe I misunderstood. But maybe you want to access the actual
Firebird data because your app does something specific with it? I
dunno...
If you want your application to be completely indepent of Firebird,
then you will have to include your own database. One way to do this is
to use the SQLite database. I would think you'd have to include the
library (probably as a JAR) and the initial data file with your
application. I'm pretty sure there's a Java wrapper for SQLite.
 
D

Dave Miller

Atharvan said:
hi
I am recently covered JavaIntro course of Javawithpassion.com, ie.,
I'm
a newbie.
Now I decided to write an application which uses a Data Base and opt
firebird because it's very small ( < 5mb ).

My doubt is that whether I need to supply firebird together with my
application to function it. ( I am using Linux but many of my friends
using windows. That's why I choose java.) Or Is the required modules
included in the package itself so I don't need to give it seperatly.
( I am using NetBeans IDE )

Please replay me considering this Question as childish.

Arun.K.R

!Atharvan!333!
{Man can be Destroyed but CANNOT be Defeated}
You need to supply all components required by your application or list
them as a requirement. How you deploy your application determines the
available architecture for providing components. Does you application
run entirely on the client side (user installs all components on their
computer) or are you using JWS or some other server / client design?
 
D

Dave Miller

Stefan said:
I am attaching my own similar question:

How much could the success of a Java application be
reduced, when one requires the target site to install
the JDK instead of the JRE?

For example, this would give applications a database
(Derby) and Java could be used as a scripting
language for such an applications (via the compiler API).
Some things that would argue against the JDK:

1. The JDK is at least 4 times the size of the JRE.
2. Some computers have the JRE installed. No computers other than those
owned by developers have the JDK.

IMO, you're better off delivering what you need instead of asking people
to put 75MB of JDK on their machine.
 
M

Mark Space

Atharvan said:
hi
I am recently covered JavaIntro course of Javawithpassion.com, ie.,
I'm
a newbie.
Now I decided to write an application which uses a Data Base and opt
firebird because it's very small ( < 5mb ).

I think if you're new to Java, you should first get a simple application
working first for yourself.

Then you'll have a better idea what it will take to get it working on
someone else's computer. Most beginners have a hard time seeing details
and it's easy to make a program too complicated. Simplify, and start
with just your own computer first.

When you do deploy, you could use JWS and then use your own computer as
a server and database. This would require no set-up at all on a
friend's computer, and it shouldn't be much different than running on
yours. Something to think about.
 
J

John B. Matthews

Mark Space said:
I think if you're new to Java, you should first get a simple application
working first for yourself.

Then you'll have a better idea what it will take to get it working on
someone else's computer. Most beginners have a hard time seeing details
and it's easy to make a program too complicated. Simplify, and start
with just your own computer first.

When you do deploy, you could use JWS and then use your own computer as
a server and database. This would require no set-up at all on a
friend's computer, and it shouldn't be much different than running on
yours. Something to think about.

Good advice.

Although I like Firebird, H2 is very robust and easy to embed, which can
make deployment easier:

<http://www.h2database.com/>

The DBSDL project is a comprehensive yet accessible example using H2:

<http://dbsdl.sourceforge.net/>

It uses ant to create, populate and test an H2 database. An included
xslt transforms the schema definition into sql and another generates the
schema documentation.

John
 
A

Atharvan :-)

What I mean is, if I use any specific DataBase, then whether I need to
supply that database package ( firebird, H2, MySQL,...) together with
my application or not?
I think now It's clear.

Surely I will check derby to know about it's possibilities.
I checked H2. Another small one as Firebird. And that DBDSL, I cannot
able to understand it. I will reread their site again.
I'll not jump into a big application before trying it on small
application, or rather How can I ?
But Mark, Thank You for your advice. What I am doing now is reading
and trying samples provided by sun, jGuru, etc...

[
I started a book organizer ( for my own purpose, and surely according
to my likings ). I think use of a database will ease coding and
efficiency.
If I do it myself in plain text files, I don't know how much efficient
it's. And I have another bad experience using plaing text files for
one of my annual project (done using C++). That is the root of this
question.
]

Arun.K.R

!Atharvan!333!
{Man can be Destroyed but CANNOT be Defeated}
 
D

David Segall

Atharvan :-) said:
hi
I am recently covered JavaIntro course of Javawithpassion.com, ie.,
I'm
a newbie.
Now I decided to write an application which uses a Data Base and opt
firebird because it's very small ( < 5mb ).

My doubt is that whether I need to supply firebird together with my
application to function it. ( I am using Linux but many of my friends
using windows. That's why I choose java.) Or Is the required modules
included in the package itself so I don't need to give it seperatly.
( I am using NetBeans IDE )
I don't know Firebird but if you had to install Firebird on your
computer to develop the application then you will have to do the same
thing on your user's computers. The existence of this deployment CD
<http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_deploy_cd>
also makes me think that you will have to ship Firebird _and_ your
application. The NetBeans build will include the JDBC drivers that
communicate with the database but not the database access code or the
actual database that your application uses. The latter will be true no
matter which DBMS you choose and your application will need to include
some way of generating your database schema on your user's computer.
 
J

John B. Matthews

"Atharvan :-) said:
What I mean is, if I use any specific DataBase, then whether I need
to supply that database package ( firebird, H2, MySQL,...) together
with my application or not? I think now It's clear.

Yes, but H2 and Derby are jars; they are perhaps easier to deploy.
Surely I will check derby to know about it's possibilities.
I checked H2. Another small one as Firebird. And that DBDSL, I cannot
able to understand it. I will reread their site again.

The xslt part is very well done, but a bit opaque at first; it's not
essential. I recommend studying the convenient ant build.xml:

<http://dbsdl.svn.sourceforge.net/viewvc/dbsdl/trunk/build.xml>

The parameters used in the "test-sql" ant target are precisely the one's
needed in your Java code.
I'll not jump into a big application before trying it on small
application, or rather How can I ?

Try writing a query against the sample database:

svn co https://dbsdl.svn.sourceforge.net/svnroot/dbsdl/trunk dbsdl
cd dbsdl
ant
javac -cp h2.jar Query.java
java -cp .:h2.jar Query

import java.sql.*;
/**
* Test enbedded H2
* @author John B. Matthews
*/
class Query
{
public static void main (String args []) throws Exception
{
Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection
("jdbc:h2:db/album-archive", "sa", "");

Statement stmt = conn.createStatement ();
ResultSet rset = stmt.executeQuery
("SELECT Albums.Name FROM Albums");

while (rset.next ()) {
String name = rset.getString(1);
System.out.println(name);
}
}
}

John
 
A

Atharvan :-)

The NetBeans build will include the JDBC drivers that
communicate with the database but not the database access code or the
actual database that your application uses. The latter will be true no
matter which DBMS you choose and your application will need to include
some way of generating your database schema on your user's computer.
Is that mean I do not supply the whole h2 stuff except h2.jar ?

Thank you for example code.

however this is the result,
==================================================================
Exception in thread "main" org.h2.jdbc.JdbcSQLException: Table ALBUMS
not found; SQL statement: SELECT Albums.Name FROM Albums [42S02-41]
at org.h2.message.Message.addSQL(Message.java:348)
at org.h2.command.Parser.parse(Parser.java:225)
at org.h2.command.Parser.prepareCommand(Parser.java:190)
at org.h2.engine.Session.prepareLocal(Session.java:174)
at org.h2.engine.Session.prepareCommand(Session.java:156)
at
org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:993)
at org.h2.jdbc.JdbcStatement.executeQuery(JdbcStatement.java:
61)
at Query.main(Query.java:15)
org.h2.jdbc.JdbcSQLException: Table ALBUMS not found [42S02-41]
at org.h2.message.Message.getSQLException(Message.java:65)
at org.h2.message.Message.getSQLException(Message.java:47)
at org.h2.schema.Schema.getTableOrView(Schema.java:199)
at org.h2.command.Parser.readTableFilter(Parser.java:756)
at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:
1200)
at org.h2.command.Parser.parseSelectSimple(Parser.java:1293)
at org.h2.command.Parser.parseSelectSub(Parser.java:1194)
at org.h2.command.Parser.parseSelectUnion(Parser.java:1081)
at org.h2.command.Parser.parseSelect(Parser.java:1062)
at org.h2.command.Parser.parse(Parser.java:338)
at org.h2.command.Parser.parse(Parser.java:219)
at org.h2.command.Parser.prepareCommand(Parser.java:190)
at org.h2.engine.Session.prepareLocal(Session.java:174)
at org.h2.engine.Session.prepareCommand(Session.java:156)
at
org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:993)
at org.h2.jdbc.JdbcStatement.executeQuery(JdbcStatement.java:
61)
at Query.main(Query.java:15)
=================================================================================

Arun.K.R

!Atharvan!333!
{Man can be Destroyed but CANNOT be Defeated}
 
J

John B. Matthews

"Atharvan :-) said:
The NetBeans build will include the JDBC drivers that
communicate with the database but not the database access code or the
actual database that your application uses. The latter will be true no
matter which DBMS you choose and your application will need to include
some way of generating your database schema on your user's computer.
Is that mean I do not supply the whole h2 stuff except h2.jar ?

Thank you for example code. however this is the result,

[...] org.h2.jdbc.JdbcSQLException: Table ALBUMS not found; [...]

If there's no table ALBUMS, you must have missed a step:

$ svn co https://dbsdl.svn.sourceforge.net/svnroot/dbsdl/trunk dbsdl
A dbsdl/RELEASE
A dbsdl/LICENSE
A dbsdl/DbSchemaDefLang.xsd
A dbsdl/h2.jar
A dbsdl/dbsdl-xhtml.xsl
A dbsdl/dbsdl-sql.xsl
A dbsdl/test.dml
A dbsdl/test.xhtml
A dbsdl/test-schema.xml
A dbsdl/README
A dbsdl/test.txt
A dbsdl/build.xml
Checked out revision 16.
$ cd dbsdl
$ ant
Buildfile: build.xml

init:

build-sql:
[xslt] Processing dbsdl/test-schema.xml to dbsdl/result.sql
[xslt] Loading stylesheet dbsdl/dbsdl-sql.xsl
[....]

build-xhtml:
[xslt] Processing dbsdl/test-schema.xml to dbsdl/result.xhtml
[xslt] Loading stylesheet dbsdl/dbsdl-xhtml.xsl
[....]

build:

clean-test-sql:

test-sql:
[sql] Executing file: dbsdl/result.sql
[sql] Executing file: dbsdl/test.dml
[sql] 66 of 66 SQL statements executed successfully
[sql] Executing commands
[sql] 1 of 1 SQL statements executed successfully

test:
[echo] SQL Test succeeded.
[echo] XHTML Test succeeded.

BUILD SUCCESSFUL
Total time: 5 seconds
$ cp ~/Desktop/Query.java .
$ javac -cp h2.jar Query.java
$ java -cp .:h2.jar Query
Rocky Mountain High
Take Me Home
You're So Vain
Footnotes
$

John
 
A

Atharvan :-)

yes ant fails

/home/kra/Music/dbsdl/build.xml:89: java.lang.ClassNotFoundException:
org.apache.tools.ant.taskdefs.optional.TraXLiaison

can you help me, I don't know ant.

Thank You

Arun.K.R

!Atharvan!333!
{Man can be Destroyed but CANNOT be Defeated}
 
J

John B. Matthews

"Atharvan :-) said:
yes ant fails

/home/kra/Music/dbsdl/build.xml:89: java.lang.ClassNotFoundException:
org.apache.tools.ant.taskdefs.optional.TraXLiaison

can you help me, I don't know ant.

Thank You

Arun.K.R

!Atharvan!333!
{Man can be Destroyed but CANNOT be Defeated}

You'll have to read the ant documentation to see how to make it
accessible on your OS. I'm using

$ ant -version
Apache Ant version 1.6.5 compiled on September 12 2006

TraXLiaison has been included since 1.3.

John
 
A

Atharvan :-)

Why I need any other database, if there is one, ie., Derby in NetBeans
IDE.
My searches helped me to use derby now and If needed (or for my
interest to know as much as I can)
look for H2, FireBird,dbsdl etc.,

Let me summarise the features of Derby,
* 2MB foot print
* 100% Java implementation
* 100% Java type 4 JDBC driver
* SQL92E standard support with many features of SQL 99
* ACID transaction support with full transaction isolation
* J2EE support via JNDI, connection pooling, and XA
* views, temporary tables and savepoints
* BLOB and CLOB data types
* row and table locking
* cost-based query optimization
* server-side referential constraints
* triggers and stored procedures
* store Java code in database, for server-side functions, triggers
or stored procedures
* can work off read-only database on CD-ROM
* data import and export
* fast database encryption option

It support Embedded mode of operation ( Which is my requirement)
together with usual Network mode.
You want to include the derby.jar only.
But that does not mean H2 and FireBird etc, are bird.
They are worth looking.

Arun.K.R

!Atharvan!333!
{ Man can be Destroyed but CANNOT be Defeated. }
 
J

John B. Matthews

"Atharvan :-) said:
Why [would] I need any other database, if there is one, i.e. Derby,
in NetBeans IDE.
[...]
[<http://db.apache.org/derby/>]

Apache Derby, based on IBM's Cloudscape, is an excellent choice; but
only you can decide if it suits your needs. As you are starting out,
your needs may be poorly defined. For now, convenience may appear high
on the list. Still, I urge you to try your new project occasionally with
other databases to discover portability and deployment problems early.

John
 
A

Atharvan :-)

Atharvan :-) said:
Why [would] I need any other database, if there is one, i.e. Derby,
in NetBeans IDE.
[...]
[<http://db.apache.org/derby/>]

Apache Derby, based on IBM's Cloudscape, is an excellent choice; but
only you can decide if it suits your needs. As you are starting out,
your needs may be poorly defined. For now, convenience may appear high
on the list. Still, I urge you to try your new project occasionally with
other databases to discover portability and deployment problems early.

John

Thank You for all your advices.
I'll notify here and particularly you after finishing up the project.
Till then bye.

Arun.K.R

!Atharvan!333!
{ Man can be Destroyed but CANNOT be Defeated. }
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top