aspose file tools*
The moose likes JDBC and the fly likes Framework for simpler stored procedure access? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Framework for simpler stored procedure access?" Watch "Framework for simpler stored procedure access?" New topic
Author

Framework for simpler stored procedure access?

David Balažic
Ranch Hand

Joined: May 15, 2008
Posts: 86
Hi!

Is there any framework that creates java stubs for stored procedures?
So I point the generator tool to my DB, it scans the stored procedures there and creates java code.

So instead of this:


I could write:


Or even: generatedCode.my_proc_2(20,4,"foo",5).getResult() and it would have the correct type for the returned data.

I tried Spring JDBC and cayenne , but the code needed to type manually is more or less the same as with plain JDBC.

Regards,
David
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Not exactly the same, but Javaranch has the Jenny code generator for database code.
David Balažic
Ranch Hand

Joined: May 15, 2008
Posts: 86
Jenny does not seem to do anything for stored procedures.
amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 514
Hi,
Have you looked at the iBatis ?
It may not generate the every part of the code but you can configure the stored procs. in a XML.
If you follow some standard writing all the stored procs. for e.g if you define all of your stored procs. would have one input and one output parameter then you can have a single DAO class interacting with all stored procs adhering to this standard. Whenever you have another procedure to be invoked you just need to add its specification in the XML file.

Regards,
amit
David Balažic
Ranch Hand

Joined: May 15, 2008
Posts: 86
amit punekar wrote:Hi,
Have you looked at the iBatis ?

Yes.
As we have predefined stored procedures, it does not offer any more that for example cayenne. (which is almost nothing, as the need for handwritten code is almost the same as with plain JDBC).
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3710
    
    5

The short answer is no, there is not a framework, in part because stored procedures differ greatly among DBMS's. Take your source code, for example, which relies on "OracleTypes" values, something obviously specific for Oracle.

For iBatis, keep in mind the goal is not necessarily to write shorter code but make the code easier to change. For example, with iBatis you can change the name of the stored procedure in XML without recompiling the Java code. Indirection can be a useful, if not immediately obvious, feature.


My Blog: Down Home Country Coding with Scott Selikoff
 
 
subject: Framework for simpler stored procedure access?