× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Dik- I have pasted below a data access class that I wrote using Spring
JDBC Template APIs.

public class RegistrationDaoImpl extends SimpleJdbcDaoSupport {

public void delete(RegistrationVO oRR){
getSimpleJdbcTemplate().update( "delete ENT_REGISTRATION where
EMPLOYEE_ID = ?",new Object[] { new Integer(oRR.getEmpID()) });
}

public RegistrationVO retrieveForAuthUID(String strUID) {
RegistrationVO oRegRec = null;
String sql = "select AUTH_USER_ID, EMPLOYEE_ID from
ENT_REGISTRATION where upper(AUTH_USER_ID) = ?";
oRegRec = getSimpleJdbcTemplate().queryForObject(sql, new
RegistrationRowMapper(), new Object[] { strUID.toUpperCase() });
return oRegRec;
}

public RegistrationVO retrieveForEmpID(int empID){
RegistrationVO oRegRec = null;
String sql = "select AUTH_USER_ID, EMPLOYEE_ID from
ENT_REGISTRATION where EMPLOYEE_ID = ?";
oRegRec = getSimpleJdbcTemplate().queryForObject(sql, new
RegistrationRowMapper(), new Object[] { new Integer(empID) });
return oRegRec;
}

public void create(RegistrationVO oRR){
int empID = oRR.getEmpID();
String sql = "insert into ENT_REGISTRATION values (?,?)";
getSimpleJdbcTemplate().update(sql, new Object[] { new
Integer(empID), oRR.getAuthUserID() });
}

public void update(RegistrationVO oRR){
int empID = oRR.getEmpID();
String sql = "update ( select * from ENT_REGISTRATION where
EMPLOYEE_ID = ?) set AUTH_USER_ID = ?";
getSimpleJdbcTemplate().update(sql, new Object[] { new
Integer(empID), oRR.getAuthUserID() });
}

public List retrieveRegistrations(RegistrationVO oRR){

String sql = "Select * from ENT_REGISTRATION where EMPLOYEE_ID =
? and AUTH_USER_ID =?";

return getSimpleJdbcTemplate().query(sql, new
RegistrationRowMapper(), new Object[] {oRR.getEmpID(),
oRR.getAuthUserID() } );

}

}


On Fri, Dec 19, 2008 at 8:07 PM, Dick Balaska <dick@xxxxxxxxxxxxx> wrote:
I use Spring JDBC all the time (and Spring MVC on webapps, and Spring
over Axis).
I haven't played with the new Spring/Eclipse integration.

Although i must be doing something wrong, because i end up with a whole
lot more than 1-2
lines of Java. For each table i have an object which contains an SQL
insert sub-object, an SQL update
object, an SQL query object, etc. And the query sub-object can be
pretty bulky depending on
how many different ways i want to look at the table.

Do you have an url which shows how to use Spring JDBC with only 1-2
lines of code?

dik

Sarah Poger Gladstone wrote:
James- I have not used the tools you mentioned. I have used Spring
JDBC template and iBatis with the AS/400 without any issues. Keep in
mind all the tools you mentioned are ORM persistence tools, meaning
they generate the SQL needed to persist and load your Java objects.
iBatis and Spring JDBC Template do not generate SQL. The programmer
writes all SQL statements. iBatis and Spring JDBC Template just reduce
the amount of boilerplate code needed to talk to a db down to
practially zilch. My Java methods that query table with 20 SQL parms
and put the results into a List of objects is only 1-2 lines of Java
code ( and 4 lines of XML ) when I use Spring JDBC Template.
When I was comparing tools, I counted lines of XML plus lines of Java
code needed to talk to the db.

-Sarah


--
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) mailing list
To post a message email: JAVA400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.