Yurttas/PL/DBL/postgres/F/02/00/01/04/dbops/DBTable.java
Jump to navigation
Jump to search
1/**
2 * Copyright(C) 2005
3 * All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
4 *
5 * Permission to use, copy, modify, and distribute this
6 * software and its documentation for EDUCATIONAL purposes
7 * and without fee is hereby granted provided that this
8 * copyright notice appears in all copies.
9 *
10 * @date : February 1, 2005.
11 * @author : Salih Yurttas.
12 */
13
14
15package dbops;
16
17import java.sql.*;
18import java.net.*;
19
20import java.util.*;
21
22public class DBTable {
23
24 protected Connection con;
25
26 public DBTable(Connection con)
27 throws SQLException
28 {
29 this.con = con;
30 }
31
32 public boolean setStatement(String table)
33 throws SQLException
34 {
35 Statement st = con.createStatement();
36 st.executeUpdate(table);
37 return true;
38 }
39
40 public ResultSet getStatement(String query)
41 throws SQLException
42 {
43 Statement st = con.createStatement();
44 ResultSet rSet = st.executeQuery(query);
45 return rSet;
46 }
47
48 public Vector getTableNames(String query)
49 throws SQLException
50 {
51 Vector tables = new Vector();
52
53 try {
54 Statement st = con.createStatement();
55
56 ResultSet rs = st.executeQuery(query);
57
58 ResultSetMetaData metaData = rs.getMetaData();
59 while(rs.next())
60 tables.addElement(rs.getString(1));
61 }
62 catch(SQLException sqle) {
63 System.out.println("Error in getTableNames");
64 throw sqle;
65 }
66
67 return tables;
68 }
69
70}