/*
 * CreateDbLogic.java
 *
 * Created on 2007/02/01, 16:55
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package weber_4_0_sample.org.itscool.sample_db;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import org.itscool.commons.connection.ConnectionController;

/**
 *
 * @author ios
 */
public class CreateDbLogic {
    public static final String LINE = System.getProperty("line.separator");
    
    public static void main(String[] argv) throws Exception{
    }
    
    public void loadSql(){
        //ConnectionController.init();
//        File inputFile = new File("DropTable.sql");
//        FileReader in = new FileReader(inputFile);
//        BufferedReader br = new BufferedReader(in);
//
//        String line;
//        while ((line = br.readLine()) != null) {
//                System.out.println(line);
//        }
//
//        br.close();
//        in.close();

        //ConnectionController.destory();
    }
    
    public void initializeDatabase(){
        dropForignKey();
        dropTable("WEBER_USER");
        
    }
    
    public void dropForignKey(){
        String sql = "alter table WEBER_USER drop constraint fk_WEBER_USER_ROLE_ID";
        ConnectionController.executeOnCommit(sql.toString());
    }
    
    public void dropTable(String tableName){
        StringBuffer sql = new StringBuffer();
        sql.append(" DROP TABLE ").append(tableName);
        ConnectionController.executeOnCommit(sql.toString());
    }
    
    public void createUserRole(){
        StringBuffer sql = new StringBuffer();
        sql.append("CREATE TABLE ");
    }
    
    
    
}
