コード例 #1
0
ファイル: AudioDao.java プロジェクト: vnedvyga/AudioShopWeb
 @Override
 public boolean add(Audio item) {
   try {
     statement.executeUpdate(
         "INSERT INTO "
             + TABLE_NAME
             + " ("
             + COLUMN_NAME
             + ","
             + COLUMN_DURATION
             + ","
             + COLUMN_PRICE
             + ","
             + COLUMN_ARTIST_ID
             + ","
             + COLUMN_ALBUM_ID
             + ") VALUES('"
             + item.getName()
             + "','"
             + item.getDuration()
             + "','"
             + item.getPrice()
             + "','"
             + item.getArtistId()
             + "','"
             + item.getAlbumId()
             + "');");
   } catch (SQLException e) {
     e.printStackTrace();
     return false;
   }
   return true;
 }
コード例 #2
0
ファイル: AudioDao.java プロジェクト: vnedvyga/AudioShopWeb
 @Override
 public boolean update(Audio changed) {
   try {
     statement.executeUpdate(
         "UPDATE "
             + TABLE_NAME
             + " SET "
             + COLUMN_NAME
             + "='"
             + changed.getName()
             + "', "
             + COLUMN_PRICE
             + "='"
             + changed.getPrice()
             + "', "
             + COLUMN_DURATION
             + "='"
             + changed.getDuration()
             + "', "
             + COLUMN_ARTIST_ID
             + "='"
             + changed.getArtistId()
             + "', "
             + COLUMN_ALBUM_ID
             + "='"
             + changed.getAlbumId()
             + "' WHERE "
             + COLUMN_ID
             + "="
             + changed.getId()
             + ";");
   } catch (SQLException e) {
     e.printStackTrace();
     return false;
   }
   return true;
 }