1 package migratool.datasources;
2
3 import java.sql.ResultSet;
4 import java.sql.ResultSetMetaData;
5 import java.sql.SQLException;
6 import java.sql.Statement;
7 import java.util.Collection;
8 import java.util.Vector;
9
10 import migratool.model.BDdescription;
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 public class OriginDataSource extends AbstractOriginDataSource{
38
39
40
41
42 public OriginDataSource(BDdescription fromDescrition) {
43 super(fromDescrition);
44 }
45
46
47
48
49
50 public LogicTable getData(){
51 ResultSet rs;
52 Statement stmt;
53 LogicTable results = new LogicTable();
54 Vector nomeColunas = null;
55 Vector linhas = null;
56 try {
57 stmt = dbConnection.createStatement();
58 rs = stmt.executeQuery("select * from " + originDescription.getTableName());
59
60 nomeColunas = new Vector();
61 linhas = new Vector();
62 ResultSetMetaData rsmd = rs.getMetaData();
63
64 for (int i =1; i <= rsmd.getColumnCount(); ++i)
65 nomeColunas.addElement(rsmd.getColumnName(i));
66 while (rs.next()){
67 linhas.addElement(getProximaLinha(rs, nomeColunas));
68 }
69 } catch (SQLException e) {
70 e.printStackTrace();
71 }
72
73 results.setNomeColunas(nomeColunas);
74 results.setLinhas(linhas);
75
76 return results;
77 }
78
79 public String toString(){
80 return "OriginDataSource";
81 }
82
83 public Collection getDataTable() throws DataSourceException, igis.datasources.DataSourceException {
84 return null;
85 }
86 }