Simple database web application with Eclipse and Glassfish - java

I just started to learning Eclipse with Glassfish server. I was looking around how can I make simple database web application, but can't figure out yet.
I downloaded the Glassfish bundle for Eclipse.
I need to create simple database ( perhaps one table ), and connect the database with simple web application. How to do that in Eclipse , can you give me some step by step link how can I do this
Thank you

For the database you could do worse than use JavaDb, which comes as standard with Java 6. Check out the JDBC tutorial for details on interfacing Java to a database.

If you decide to use Apache Derby as your database, a version of it called JavaDB comes with jee6 + Glassfish bundle, you can read this tutorial about how to connect to it and create tables from within Eclipse. You need to download the Apache Derby plugin.
This has nothing to do with Glassfish, however the example shows you how to connect to it from a normal Java desktop application using JDBC.

This Tip Of The Day seems to have the info you are looking for....

At this point, you have a webapp server and an IDE. Both of which are designed to be semi-agnostic when it comes to databases. The next choice is how you want to interact with the database. Then you should be able to find more information and examples on how to start constructing your webapp.
I'd suggest going with spring and stripes (http://www.springsource.org/ and http://www.stripesframework.org/display/stripes/Home respectively), but that's a personal choice.

Related

Complete Glassfish Guide with MySQL

I want to start a JavaEE project, I've read about where to start with JavaEE and most of them were directed to Glassfish. I installed it, and was able to get to the localhost, however I don't know where to go next. Is there a complete guide or tutorial on how to use Glassfish? Also if I can use MySQL with Glassfish for the JavaEE project.
Of course, you can use MySQL. You can find a complete guide for setting up a connection with MySQL for Glassfish here.
An IDE like Netbeans is probably the easiest way to get started with JavaEE. You only need to add your freshly installed Glassfish server to Servers (under Services tab), then you can start working on your project.
However, it may be advisable not to use IDE at the beginning, since it hides from you some essential operations. Therefore, you'd better start by making your first 'test' project manually (I mean building and deploying).
There are several books for beginners to JavaEE platform and they usually start with a decent introduction on how to accomplish that. For example this one covers the topic in details:
Beginning Database-Driven Application Development in Java EE by Yuli Vasiliev.

Is it possible to embed a MySQL database server into a Java servlet?

I am in a situation where I am being asked to make a single WAR file that runs Wordpress. Using Quercus, Tomcat and httpd+mod_rewrite I was able to make a WAR file containing everything except the database, which I ran externally. However, I'm not sure how I might go about removing the dependency upon an external database (and, frankly, this whole endeavor seems like a bad idea to me).
This article describes how Wordpress has been successfully deployed on the Google App Engine and hence without needing MySQL, but this was done using JPA.
Instead of embedding a MySQL instance, if I could use an external MSSQL database connection instead that would be fine too. (This is an old post, but it seems to suggest that real MySQL is the only supported database for Wordpress.) Is the most viable option to attempt to replace each MySQL call in the Wordpress source code to a MSSQL call? Is there some kind of compatibility/translation layer that I could use instead? (I saw this question, but the solution will not work in my case.)
UPDATE: I came across MySQL-JE, but it looks out of date and not quite complete enough (not sure how I would tell Quercus/PHP to communicate with it). Has anyone used it? If so, do you think it would help solve this problem?
Embedded Database
According to this chart, MySQL is not built for embedded use.
I can point you to two pure Java database engines for embedding in a Java app. Both are open-source, free of cost, and under active development. Both have a good pedigree with a long line of database development history behind them.
H2
Derby
WordPress Requires MySQL
According to this WordPress Requirements page, specifically MySQL is required. That's annoying. The main point of SQL is to avoid database-vendor lock-in.

Is it possible to use derby from apache in Eclipse now that they stopped developing the derby plugin for Eclipse?

I would like to use Derby from apache in order to include database management on a desktop application that I'm currently developing.
Unfortunately I figured out that they have stopped developing this plugin and all the tutorials I've read online refer to this plugin.
So my question is, how can I use the latest version of Derby on eclipse? What steps should I follow? I would like my application to be standalone and easily transferable.
thanks in advance
Apache Derby is just like other databases that provide interface through JDBC. You don't need a specific plugin to connect with Derby. Just use the usual JDBC routines.
Basic steps:
If you want to use the latest Derby version, first you need to download it from here
You need to include the jar in your classpath.
You just need to make connections and perform queries using JDBC, as better explained at the Oracle JDBC Tutorial.
Ditto pram.
I'm using Derby in a Java app I'm developing with Eclipse, and I didn't know there was a plug-in. I connect to Derby like I would to any other database. I use the Derby command-line interface to manage the tables. \
(One feature of other db's I would have liked to see in Derby: having SQL extensions to display db metadata, like MySql's "show" and "describe" commands. Derby has these in the command-line interface, but they're apparently implemented there rather than in the SQL engine itself, so you can't use them outside of the CLI. Bummer. When I'm developing, I often build an ad hoc query screen into the app that lets me type in and execute arbitrary queries. (And no, I don't deploy this to public websites.) But I digress.)
I don't know what the plug-in does for you. I've never used an Eclipse plug-in for any database.
The plug-in is still available in source form, and instructions for building it are available on the Derby website: http://svn.apache.org/viewvc/db/derby/code/trunk/plugins/eclipse/Readme.txt?view=markup
From time to time the instructions for building the plug-in change; you might wish to check into the status of this issue for further updates: https://issues.apache.org/jira/browse/DERBY-5272

Integrating data-provider to application without using sql or nosql servers

I'm creating a simple CMS software which doesn't have much data to be stored. I'm currently using mysql as my data provider and have a java application in the presentation layer. This CMS will be a standalone which means datacollection and processing will be done in a single computer.
I created a installer to install in my clients computers. But I need to setup mysql then the database as well. And my clients doesn't have sufficient IT knowledge to setup the databases themselves. So for each client I have to attend and install mysql server.
What I need is a way to integrate data-provider to the application without using mysql or any other sql or nosql server. So my clients can install it themselves using simple guided steps in installation wizards.
You can use one of embedded db, like JavaDB (ex. Derby). Support of this database is added to JRE. So all your client need is installed JRE. And you get full relational database without any installation and other stuff setup.
You can try using hsqldb or sqlite db. These dbs can be bundled with the application in memory or can use a simple file as db. Hope it helps
I found a good example here
http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javadb/
thanks every one for help

Database for dummies

I need a free database for my web app made in Java EE 6. I use glassfish server V3.0.
Could someone recommend me one that is easy to setup and use(for dummies :) )? And also some good instructions.
I just had a horrible experience trying to install MySQL 5.5. It was impossible for me to connect to the database, i was getting all the time a 10061 error, i tried everything and i just gave up. Just please dont tell me MySQL :)
Also i want to mention that i use winXP SP3 and my programming IDE is eclipse Helios
There's little that's easy about Oracle.
I'd recommend PostgreSQL if MySQL won't work for you. It has a very nice admin console, too. You might like that better than the command shell.
Or maybe Derby, the database that's built into JDK 6 and higher.
Or perhaps Hypersonic SQL.
Mysql. :) Seriously, it is THE most popular open source database. Postgres is good too, but Mysql is undoubtedly more popular and you're going to find more hosts that provide you a Mysql database, for instance (if that matters).
Try a Windows LAMP (Linux, Apache, Mysql) package. For instance, try WAMP (http://www.wampserver.com/en/). This will come with phpmyadmin, a pretty good web based admin console for Mysql.
Otherwise, you could try SQL Server Express, a free version of Microsoft SQL Server: http://www.microsoft.com/express/Database/.
Depending on what you're developing for, I'm partial to Oracle Express Edition. It's free, relatively easy to get going, and everything you write against it, will work on an full blown Oracle database. (Since it is basically a full blown Oracle 10g database, just limited).
Note that Glassfish comes with JavaDB (aka DerbyDB) bundled. So you do not need to install any other database (if JavaDB fits your needs)
You can start the database server with the followind command:
glassfish-install/bin/asadmin start-database --dbhome directory-path
See this page for more information.

Categories

Resources