public class CategoryDAO {
public void save ( Category c ) throws Exception {
Connection con = null ;
PreparedStatement ps = null ;
try {
Class . forName ( DB . JDBC _ DRIVER );
con = DriverManager . getConnection ( DB . JDBC _ URL , DB . JDBC _ USER ,
ps = con . prepareStatement (" insert into t _ category value ( null ,?,?)"); ps . setString (1, c . getName ());
ps . setString (2, c . getDescription ());
ps . executeUpdate ();
} catch ( Exception e ){
e . printStackTrace ();
throw new Exception ("数据库异常:"+ e . getMessage ());
DB . JDBC _ PASSWORD );
} finally (
if ( ps != null ) ps . close (); if ( con != null ) con . close ();