aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes Java app with database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Java app with database" Watch "Java app with database" New topic
Author

Java app with database

George Holloway
Greenhorn

Joined: Jan 28, 2012
Posts: 3

Hello all first post here,

Recently i made a simple java application that connects to a local database and gets contact information. You can edit the info and add new contacts as well as save it to the database. This was all nice since i made it in NetBeans and it was quite easy really since it took few click and the code is generated. But now i have to make the whole thing again but this time in Eclipse and from scratch (as far as the connection goes). I'm using Eclipse Helios 3.6.2 version btw. So i downloaded the WindowBuilder v 1.2.0 and started designing the application. Unfortunately i don't have knowledge on how to bind the columns and the rows, because i only know the basics of java. So my questions are:

1. First i created the JScrollPane for the table. When adding the JTable inside i get three spaces on where to add the table. I am guessing that viewpoint is the one i need? And how do i get the names of the columns?
2. Which packages can i use for the binding of the columns from the database to the table? If that is what i need at all since i am confused with the entityManger and what it does. ?

An example will be nice as well . That's all for now back to reading and looking at some code.
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

I didn't get your question but here is my shot:
You used NetBeans's Matisse Swing GUI builder to build your UI and now you want to rebuild the same UI in Eclipse's WindowBuilder?
George Holloway
Greenhorn

Joined: Jan 28, 2012
Posts: 3

So far this is what i have. This is the java main view of the application




I also have a connection to my local database



In the main class is the table. The database is made out of three columns name, last_name and phone. I don't know how to display the columns data from the database to my table in the application, and also how to add new contacts with the buttons. I have more code but i can't seem to make it work. I know i have to put some code in the actionListener of the buttons and some in the connection to get me a result but don't know how to add all that in the table. Hope i didn't confuse you. Any help would do thanks.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

Welcome to the JavaRanch, George!

There are 2 problems with learning technology by way of an IDE.

The first problem is that when the IDE does all the work for you, you don't need to understand how or why things are being done. This can lead to appalling gaps in one's education. And, more importantly, when it comes time to improve or maintain the app beyond what the IDE can do for you, you can end up doing really awful things because you don't really know what you are doing.

The second problem is that IDE-based code generators more often than not generate constructs that only work within the context of that IDE. And often, only a specific version of that IDE. So if you switch to another IDE, or get pulled in to do an emergency fix years later, you're left high and dry.

Which is why we not-so-jokingly say around here that the best IDE to learn Java with is Windows Notepad. Problem #2 is also why my production software isn't built by IDEs at all (I use Maven or Ant). In addition to having serious burn scars from the obsolete IDE problem, not all of my production build machines are GUI machines.

IDEs can be a big help and a work-saver, but they're no replacement for knowing what you're doing. When you actually have to create everything by hand, you get a little more respect for what's going on. And a lot more understanding.

Case in point. Your code sample is using vanilla Swing (no vendor-specific stuff) and raw JDBC. But you asked a question about "entityManager". The EntityManager is a class that serves the same basic purpose as the JDBC Connection, but at the more abstract level of an Object Relational Manager (ORM) system. The Java Persistence Architecture (JPA) ORM, specifically. Yes, you can use JPA to populate POJOs from a database - and vice versa, but JPA is a fairly complex technology all by itself.

I'm guessing that the IDE is offering a wizard to do the grunt work on JPA. For what it's worth, I find those particular wizards so frustrating that I do all my ORM stuff manually or with command-line tools. In any event, I'm not sure that you want that much extra complexity in a "beginner" app.


Customer surveys are for companies who didn't pay proper attention to begin with.
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

I learnt java using eclipse (didn't use any other generator than code complete) and I came to interview questions and I could tell them what was needed and the eclipse shortcut to write that code (instance of being a classic example).
I had never written a class from scratch so didn't know what went above the first constant/member variable, eclipse had always done that for me.

But it got me writing production code quicker...
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

Wendy Gibbons wrote:I learnt java using eclipse (didn't use any other generator than code complete) and I came to interview questions and I could tell them what was needed and the eclipse shortcut to write that code (instance of being a classic example).
I had never written a class from scratch so didn't know what went above the first constant/member variable, eclipse had always done that for me.

But it got me writing production code quicker...


It's a good thing you weren't interviewing with my last large-corporate employer, then. They didn't use Eclipse. They were an IntelliJ shop.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Java app with database