I have thought of creating my first database application for one of my projects using Oracle and Java. I have chosen Netbeans as my development environment. I have a few questions to getting started.
This will be a data intensive (yet still for a college project) database application. I do not need 1000 user concurrency or any other very advanced features but basic stuff such as triggers, stored procedures etc. Will the 11g "Express" (XE) suffice for my requirements?
Do i need any Java to Oracle bridge (database connectivity driver eg. ODBC etc) for Netbeans to connect to the oracle database? If yes, what are they? Does Netbeans support Oracle databases natively?
Any easy to follow guide on how do I connect to the database and insert/retrieve/display data on a J2SE application? (I know that i should Google this but if there's any guide previously followed by anyone and is considered easy, it would be greatly appreciated.)
There are several different ways to access databases using Java. I'm assuming you are wanting to use JDBC, which is included in all recent JDK's. There are other layers on top of JDBC like Hibernate that may make things cleaner for larger applications, but may also be too steep a learning curve if you have a project to complete and submit.
To answer your questions in order:
I think it's highly likely that Oracle 10g Express Edition will do what you need for a college project. It's pretty much the 10g Standard Edition with a 4GB limit on data size.
You will need a JDBC driver to access the database from Java. It comes with XE, and is installed in <XE client install dir>/jdbc/lib/ojdbc14.jar
Sun have an introduction to JDBC here.
Related
I was wondering if I could get some advise/suggestions if anyone has experience with the following situation.
So I want to develop a java web app that "talks" with a database that is already built out in .NET. I have experience coding java web apps in eclipse that talked to MySQL DBs so I don't think the database language is that concerning.
What methods would you go about to implement this? Are there certain programs that are more useful than others? What frameworks should I use? Also, examples that I found on the web seem so dated style wise, are there things I can do to web apps coded in eclipse to give it some pop?
Thank you in advance
Microsoft has a JDBC driver for MSSQL.
Refer to: http://msdn.microsoft.com/en-us/sqlserver/aa937724.aspx
Call me JDBC on any database.
In these days, from the point of database vendor, they will give us a nice library (driver) to communicate their product from any (widely using) programming language.
Java is a big dealing programming language in world wide, so don't worry about database connection as this can be done by a jar featuring JDBC.
So your challenge is JDBC driver to suite and map to required database brand and its version.
You just need to worry to be right plug between the database's version and the JDBC driver library (jar file) version. Don't care on any database of MySQL, Oracle, MSSql or so on.
Java app -> JDBC Driver -> Database
Famous database's JDBC drivers;
MSSql JDBC Driver (What you need one?)
MySql JDBC Driver
Oracle JDBC Driver
I've been assigned the task of making our Java web application work with Oracle Database. I am not sure where to start. I was hoping for an experience similar to working with MySQL or PostgreSQL, but no such luck.
The answer to this question will be list of steps for installing and deploying an Oracle Database for development use, basic operations such as starting and stoping, creating and dropping schemas, and perhaps even JDBC connection parameters.
A little bit of background about my project (although ideally the answer to this question will be as general purpose as possible and not be tied to the specifics of my environment):
Java (and Scala) web apps deployed in Tomcat
Hibernate (currently connected to PostgreSQL and MySQL)
Developer workstations run OS X; production deployments are to Red Hat Enterprise Linux
Firstly, don't think about Oracle on OS X. You'll need Linux (or Windows), maybe on a virtual machine/
Then decide whether you'll be using Oracle 10g or 11g. 10g has a free Express Edition which is relatively easy to install on Linux or Windows. However, if you want 11g or bug fixes to 10g or some of the extra options (compression, partitioning...) you'll need a fully licenced version of Oracle. Depends on your load, but you can have one physical machine which is licenced for Oracle, with multiple VMs (one for each developer).
XE has a single database instance that the installer will configure to start up when you start the machine. If you are just using the VM for the database, having the database startup and shutdown with the machine is the easiest way to go.
I have not found a fundamental difference between MySQL and Oracle from a developer's point of view. It's just tables, joins, and SQL. If your database gets enormous or needs insane throughput then yes, it matters a lot. But by then you'll need a real DBA.
Download SQLDeveloper from Oracle. It is free. It will let you perform database maintenance, run SQL statements interactively, etc.
Read up on "connection pooling" and "oracle". There probably some good threads here on SO. You'll want this as it will make your servets run efficiently.
Read up on JNDI database connections. This is simply a way to specify the database connection in your Tomcat configuration so your applications don't have to know anything about the database. You'll be able to move your war files from test to QA to prod with less difficulty.
Hibernate is the trickiest thing of the bunch! Keep it simple! I highly recommend you reverse engineer your model classes from the database and never manually modify them. You can also generate your DAOs (recommended) but you will modify those.
Use standard proper database design as you'll have to play fewer games with Hibernate. For example, always put a numeric PK on each table, and use an Oracle sequence to populate it. Always use FKs when appropriate. Try to normalize your data to a practical extent.
Use Ant or Maven for your builds. Don't do anything by hand.
Use SVN or similar.
That's the biggies for now.
If your database is relatively lightweight and doesn't heavily rely on Oracle-specific features, I would recommend you to use XE for development. In the other case, it might make more sense to dedicate a separate box for running Oracle for development.
As for the basic steps you mentioned, the later versions of oracle come with a rather nice web-frontend(which looks like that) that can handle all of these maintenance tasks. If you would need something better and more responsive, go for Oracle SQL Developer, which is a desktop application somewhat similar to pgAdmin.
Installation is also much easier with the newer versions of Oracle (10g and up), so you should not have any problems with that.
Edit: On memory optimization (if you insist on having an Oracle instance on your workstation and your database is relatively light), check this thread since it provides a multitude of good hints.
Is there a "best" or more popular database for standalone Java app?
I'm currently writing by hand, but I would like to know what is commonly done, if there is something that is commonly done.
update: talking about small app (may grow, but its small for now)
I would suggest using something like SQLite with SQLiteJDBC.
It also sounds like HyperSQL and Derby (which ships with certain Java versions) are popular choices.
Java 6 ships with Derby (renamed JavaDB). It can be used in memory or server mode.
HyperSQL (HSQLDB) is also popular.
For development purposes, I often use the Hypersonic SQL Database (HSQLDB). It's fast and lightweight, and good enough to get started.
For a bigger application, I'd go for Derby, which supports more options.
The main competitors - HyperSQL (HSQLDB), JavaDB (Derby) and SQLite (not java-based) were mentioned.
There are a few other options:
db4o - object database
FirebirdSQL - not java-based.
Jackrabit - a content repository (not RDBMS) supporting embedded mode.
HSQLDB is a well-established option.
JavaDB comes with the development kit
apart all those mentioned here, one can also go for H2 database which is light and can be used in-memory or in server mode.
For a SQL option, you could try MySQL, SQL Server, PostgreSQL, or Oracle. Those seem to be the most popular among Java developers.
If you want something NoSQL, MongoDB is the most popular choice with Java developers based on StackOverflow data from 2022.
You can find more information on the metrics used to make that determination in this article.
Can anyone list the requirements (i.e. any books, tutorials, libraries etc) to build an application in Java, which could communicate with my MySQL Database which is running on web.
I am running an online webstore built in PHP and MySQL. I would like to build a Java Application through which I can (CRUD) Products, Categories, Orders etc.
My Database is already built in MySQL and all the data is present in my online site. So I only need to work on a GUI App which can access my Store's data.
Here is an example application built in Delphi which acts as a Front End (Store Manager) for oscommerce shopping cart.
What technologies do I need for creating Windows GUI in java and Database Application to communicate with my Online Store's Database. ?
I have found some tutorials:
https://web.archive.org/web/20120126005135/http://www.netbeans.org/kb/docs/java/gui-db.html
https://web.archive.org/web/20101125223754/http://www.netbeans.org/kb/docs/java/gui-db-custom.html
https://web.archive.org/web/20090228020221/http://www.netbeans.org/kb/articles/mysql-client.html
https://web.archive.org/web/20110923093326/http://www.netbeans.org/kb/docs/java/gui-db.html
Are the above tutorials enough?
UPDATE:
How about the following books:
1). JDBC Practical Guide for Java Programmers
2). JDBC API Tutorial and Reference, 3rd Edition
Would these be enough for a beginner?
For the database communication you're going to need a JDBC driver for MySql.
Check out the official Sun JDBC tutorial for details on how to use this to access your database.
also Java Swing tutorial or check out SWT if you prefer faster and more native looking UI
Why don't you just use the MySQL tools directly or any Javabased database viewer? If it is only for you you will save quite a bit of time.
DBvisualizer has worked well for me.
http://www.minq.se/products/dbvis/
I am looking for some advice on what should I concentrate my efforts to get the needed skills to become a Java developer for Oracle applications. I'm bit confused as there are lot of technologies in the Java world. Where should I start? What to avoid? Is JDeveloper a good IDE for a beginner?
You're question is a little bit too vague in order to give a proper answer...
If you plan to query the Oracle Database from an External Java Program (Either within a Swing Application or an Application Server) then you need to learn 2 core APIs:
JDBC (Java Database Connectivity)
JPA (Java Persistence API)
JDBC is the core API that allows a Java Program to interact with any RDBMS so you should at least know how it works so whenever you have to dig into low-level code, you will actually know what's happening.
JPA is the latest Java API for Persistence which basically allows one to map Plain Old Java Object (AKA PoJo) to RDBMS Table Structures. There are multiple known implementation available but I would recommend Hibernate or TopLink as good starting points.
After that, you can start to dig into other known frameworks like the Spring Framework for some other RDBMS related APIs.
To become an Oracle Developer there is a bit more to learn than jdbc. You should take a look at the Oracle web site. It is kind of slow and not very intuitive but has a lot of good information. There are OUGs that have good info as well.
If you just want to access Oracle via JAVA then you should use a framework such as Spring. Takes away the pain of jdbc. Lets you write sql and map it to objects.
If you don't know PL/SQL it might be good to learn what it is.
My two cents from working with Oracle for the past 7 yrs.
You should be able to do everything related to Oracle using JDBC, so make sure you bone up on that API. Other than that, it depends on the type of application. Standalone apps may use Swing (the Java UI toolkit) or in the future JavaFX, which is supposed to make Swing obsolete and may do so in a few years. Web/enterprisey apps will make use of Java Enterprise Edition, so take a look at the servlet API, and if the app uses Enterprise JavaBeans, look at the Java Persistence API, which you would probably be using instead of JDBC.
I haven't used JDeveloper, but I haven't found anything wrong with the free IDEs like Eclipse or Netbeans, and my personal favorite is JetBrains's IntelliJ IDEA.
There's really nothing specific you need to learn to be an oracle devloper per se. Obviously you need to learn oracle sql syntax, and all the standard rdbms theory that goes along with database programming in general. The Java libs for database support are pretty easy to pick up and run with. I'm sure you can find a tutorial on the web by a quick google search.
As for IDE I'd recommend Eclipse. It's a bit cumbersome at times, but the number of plug-ins available is staggering, and it has great refactoring and code completion support.
Expert Oracle JDBC Programming is a book aimed directly at developers who want to use Java with Oracle. Before you make even that small monetary investment though, you might want to check out the JDBC tutorial published by Sun.
You can use JDeveloper and try to find some tutorials for it (I actually had some from my university). It integrates well with rest of Oracle stack (db and application server). Down site is that although you can download some developers editions to run for personal usage, running Oracle db + Oracle application server + JDeveloper on a machine that has less then 4GB of ram and one core is not really peasant experience.
Your question is very simple so I have listed a few simple steps to start developing a Java application using Oracle technologies.
Install Oracle XE Database.
Install [JDeveloper]. Choose the install with Weblogic if you are developing a J2EE application.
Build and run a jdbc application using the [sample code] or use the wizard in JDeveloper.
Install SQL Developer for writing stored procedures.
Steps 3. and 4. are optional. You now have everything you need to build either a proof of concept or an enterprise grade database application, using simple wizards and without re-inventing the wheel.
You mentioned developing an Oracle Application. It's best to leave the development of Oracle's packaged Application to Oracle itself but if you want to integrate your custom java application with Oracle's packaged application then use Oracle's SOA Suite.
Cheers
KB