Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Databases > Re: Class desig...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 7 Topic 3595 of 3876
Post > Topic >>

Re: Class design for DB code

by Andrey Ryabov <andrey_ryabov@[EMAIL PROTECTED] > Nov 17, 2007 at 11:55 PM

The previous class is a part of the framework I've developed ages ago
being inspired by the way Spring improved working with jdbc.
It manages resources such as connections, resultsets, statements and
provide you with the ability to make most common queries easily for
example:

if you want to perform update your code might look like that:

    BigInteger objectID = new BigInteger("123455");
    jdbc.executeUpdate("update nc_objects set name = ? where object_id
= ?", "NewName", objectID);


selecting list of integers:

    List childIDs = jdbc.selectForList("select object_id from
nc_objects where parent_id = ?",
               JDBCTypeConverters.NUMBER_CONVERTER, new Object[][]
{{parentID}});


working with a result set:
 Integer orderNumber = new Integer("...");
    Integer result = jdbc.executeSelect("select * from  nc_objects
where parent_id = ? and order_number = ?",
                   parentId, orderNumber, new
ResultSetHandler<Integer>(){
            public Integer onResultSet(ResultSet resultSet) throws
SQLException {
              // work with result set here ...
              while (resultSet.next()) {//...
              }
              return 1;
           }
         });
 




 7 Posts in Topic:
Class design for DB code
"Durango2008" &  2007-11-18 05:27:23 
Re: Class design for DB code
Andrey Ryabov <andrey_  2007-11-17 23:42:18 
Re: Class design for DB code
David Harper <devnull@  2007-11-18 07:54:55 
Re: Class design for DB code
Andrey Ryabov <andrey_  2007-11-17 23:55:20 
Re: Class design for DB code
Andrey Ryabov <andrey_  2007-11-18 00:14:07 
Re: Class design for DB code
Doug Morse <morse@[EMA  2007-11-20 13:24:29 
Re: Class design for DB code
Andrey <andrey_ryabov@  2007-11-30 07:40:05 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Dec 4 0:01:29 CST 2008.