public Term createTerm(final String name, final String slug) throws SQLException {

      Connection conn = null;
      PreparedStatement stmt = null;
      ResultSet rs = null;
      Timer.Context ctx = metrics.createTermTimer.time();
      try {
         conn = connectionSupplier.getConnection();
         stmt = conn.prepareStatement(insertTermSQL, Statement.RETURN_GENERATED_KEYS);
         stmt.setString(1, name);
         stmt.setString(2, slug);
         stmt.executeUpdate();
         rs = stmt.getGeneratedKeys();
         if(rs.next()) {
            return new Term(rs.getLong(1), name, slug);
         } else {
            throw new SQLException("Problem creating term (no generated id)");
         }
      } finally {
         ctx.stop();
         closeQuietly(conn, stmt, rs);
      }
   }
public Term createTerm ( final String name , final String slug ) throws SQLException { Connection conn = null ; PreparedStatement stmt = null ; ResultSet rs = null ; Timer . Context ctx = metrics . createTermTimer . time ( ) ; try { conn = connectionSupplier . getConnection ( ) ; stmt = conn . prepareStatement ( insertTermSQL , Statement . RETURN_GENERATED_KEYS ) ; stmt . setString ( 1 , name ) ; stmt . setString ( 2 , slug ) ; stmt . executeUpdate ( ) ; rs = stmt . getGeneratedKeys ( ) ; if ( rs . next ( ) ) { return new Term ( rs . getLong ( 1 ) , name , slug ) ; } else { throw new SQLException ( "Problem creating term (no generated id)" ) ; } } finally { ctx . stop ( ) ; closeQuietly ( conn , stmt , rs ) ; } }
Creates a term.
@param name The term name.
@param slug The term slug.
@return The created term.
@throws SQLException on database error.