001/* 002 * To change this template, choose Tools | Templates 003 * and open the template in the editor. 004 */ 005package csheets.ext.database.core; 006 007import csheets.core.Cell; 008import csheets.ext.database.controller.ControllerExport; 009 010/** 011 * The thread responsible for the export of data to a database 012 * @author João Carreira 013 */ 014public class ThreadExport implements Runnable 015{ 016 private Cell[][] cells; 017 private String url, user, pass, tableName, dbName; 018 private ControllerExport ctrlExp; 019 020 public ThreadExport(Cell [][]cells, String url, String user, String pass, String tableName) 021 { 022 this.cells = cells; 023 this.url = url; 024 this.user = user; 025 this.pass = pass; 026 this.tableName = tableName; 027 } 028 029 public ThreadExport(Cell [][]cells, String url, String user, String pass, String tableName, String dbName, ControllerExport ctrlExp) 030 { 031 this.cells = cells; 032 this.url = url; 033 this.user = user; 034 this.pass = pass; 035 this.tableName = tableName; 036 this.dbName = dbName; 037 this.ctrlExp = ctrlExp; 038 } 039 040 @Override 041 public void run() 042 { 043 try 044 { 045 ctrlExp.connect(url, user, pass, dbName); 046 ctrlExp.setDataToExport(cells, user, pass, tableName); 047 } 048 catch(Exception e) 049 { 050 e.printStackTrace(); 051 } 052 } 053}