aspose file tools*
The moose likes JDBC and the fly likes Tool to generate a Class from MySQL table (Model Class for MVC Pattern) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Tool to generate a Class from MySQL table (Model Class for MVC Pattern)" Watch "Tool to generate a Class from MySQL table (Model Class for MVC Pattern)" New topic
Author

Tool to generate a Class from MySQL table (Model Class for MVC Pattern)

mark reusen
Greenhorn

Joined: Oct 20, 2010
Posts: 22
Hello

I'm looking for a tool to generate a Class with all the variables, getters and setters from a MySQL table.
I'm using Netbeans and Eclipse IDE to develop Webapplications.
Suggestions?

kind regards,
Mark
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Check out our own Jenny code generator.
mark reusen
Greenhorn

Joined: Oct 20, 2010
Posts: 22
I've download the jr.jar and put it in the "C:\Program Files (x86)\Java\jdk1.6.0\bin" map.
This map is in the Classpath but I receive NoClassDefFoundError.

command-line: java com.javaranch.db.Jenny tennis.properties (from the c:\temp map)

What goes wrong?


Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

You haven't specified the class path. And don't put jar files in your JDK folders. Put them somewhere else (I have a folder called C:\Javastuff for example) and point there when you specify the class path.
mark reusen
Greenhorn

Joined: Oct 20, 2010
Posts: 22
I don't understand :-(
I put C:\javastuff in the CLASSPATH (windows systemvariables). The jr.jar is also in the c:\javastuff map.
Then I do cd c:\javastuff and then "java com.javaranch.db.Jenny tennis.properties"
Result is a java.lang.ClassNotFoundException, can't find the main class com.javaranch.db.Jenny
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19784
    
  20

JAR files need to be part of the CLASSPATH variable themselves, not just the folder they are on.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Hauke Ingmar Schmidt
Rancher

Joined: Nov 18, 2008
Posts: 433
    
    2
Eclipse: If it is a JPA project (or has the JPA facet): Project's context menu, JPA tools, Generate Entities from tables. If it is not a JPA project per se, make it so temporarily.

Netbeans: IIRC in the "New" menu, Entity from Tables.

Or do I miss something fundamentally?
mark reusen
Greenhorn

Joined: Oct 20, 2010
Posts: 22
Thank's, Eclipse works fine! Now I have a Class for every Table (with all the attributes and getters and setters).
Is it also possible to generate an IO Class (with the SQL query inside) for the Table, which uses the Class mentioned above?
Hauke Ingmar Schmidt
Rancher

Joined: Nov 18, 2008
Posts: 433
    
    2
As you wouldn't write SQL code yourself with JPA the tools I mentioned don't have support for this.

If you were using Spring then you could look into the JdbcDaoSupport. If you really need to write the SQL yourself a framework like iBatis could help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tool to generate a Class from MySQL table (Model Class for MVC Pattern)