Package net.sourceforge.javautil.database.mysql.memorytable

Source Code of net.sourceforge.javautil.database.mysql.memorytable.EncryptedMemoryTableManager

package net.sourceforge.javautil.database.mysql.memorytable;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;

import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.sql.DataSource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import net.sourceforge.javautil.common.BackupUtil;
import net.sourceforge.javautil.common.IOUtil;
import net.sourceforge.javautil.common.encryption.EncryptionIOHandler;
import net.sourceforge.javautil.common.encryption.IEncryptionProvider;
import net.sourceforge.javautil.common.exception.ThrowableManagerRegistry;
import net.sourceforge.javautil.common.io.IVirtualDirectory;
import net.sourceforge.javautil.common.io.IVirtualFile;
import net.sourceforge.javautil.database.encryption.EncryptedTable;
import net.sourceforge.javautil.database.encryption.EncryptedTableManager;

/**
* This will detect mysql Memory based tables and tag them for encryption/decryption.
*
* @author elponderador
* @author $Author: ponderator $
* @version $Id: EncryptedMemoryTableManager.java 2297 2010-06-16 00:13:14Z ponderator $
*/
public class EncryptedMemoryTableManager extends EncryptedTableManager {
 
  protected List<EncryptedTable> tables;

  public EncryptedMemoryTableManager(IEncryptionProvider provider, DataSource mysqlDataSource, IVirtualDirectory storageDirectory) {
    super(provider, mysqlDataSource, storageDirectory);
  }
 
  @Override public List<EncryptedTable> getEncryptedTables(Connection connection) {
    if (this.tables == null) {
      this.tables = new ArrayList<EncryptedTable>();
     
      try {
        Statement statement = connection.createStatement();
        ResultSet set = statement.executeQuery("SHOW TABLE STATUS");
        set.beforeFirst();
       
        while (set.next()) {
          String engine = set.getString(2);
          if ("memory".equalsIgnoreCase(engine)) {
            this.tables.add(new EncryptedTable(this, set.getString(1)));
          }
        }
      } catch (SQLException e) {
        throw ThrowableManagerRegistry.caught(e);
      }
    }
    return tables;
  }

}
TOP

Related Classes of net.sourceforge.javautil.database.mysql.memorytable.EncryptedMemoryTableManager

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.